Fix duplicate --reactor option registration in conftest.py

This commit is contained in:
aliowka 2026-06-21 20:17:03 +03:00
parent e6b785cd04
commit ac8b132605
1 changed files with 19 additions and 0 deletions

View File

@ -59,6 +59,25 @@ except ImportError:
def pytest_addoption(parser, pluginmanager):
if pluginmanager.hasplugin("twisted"):
return
# Check if --reactor is already added by another plugin
has_reactor = False
for opt in getattr(parser, "_anonymous", None) or []:
if hasattr(opt, "names") and "--reactor" in opt.names():
has_reactor = True
break
if not has_reactor:
for group in getattr(parser, "_groups", None) or []:
for opt in getattr(group, "options", []):
if hasattr(opt, "names") and "--reactor" in opt.names():
has_reactor = True
break
if has_reactor:
break
if has_reactor:
return
# add the full choice set so that pytest doesn't complain about invalid choices in some cases
parser.addoption(
"--reactor",