Skip to content

Commit ddb2f4c

Browse files
committed
Fix issue where pytest.ini was ignored for some options
1 parent 8e97a8b commit ddb2f4c

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

seleniumbase/plugins/pytest_plugin.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,15 +1281,49 @@ def pytest_configure(config):
12811281
sb_config._html_report_name = None # The name of the pytest html report
12821282

12831283
arg_join = " ".join(sys.argv)
1284-
if ("-n" in sys.argv) or (" -n=" in arg_join) or ("-c" in sys.argv):
1284+
if (
1285+
"-n" in sys.argv
1286+
or " -n=" in arg_join
1287+
or "-c" in sys.argv
1288+
or (
1289+
"addopts" in config.inicfg.keys()
1290+
and (
1291+
"-n=" in config.inicfg["addopts"]
1292+
or "-n " in config.inicfg["addopts"]
1293+
)
1294+
)
1295+
):
12851296
sb_config._multithreaded = True
1286-
if "--html" in sys.argv or " --html=" in arg_join:
1297+
if (
1298+
"--html" in sys.argv
1299+
or " --html=" in arg_join
1300+
or (
1301+
"addopts" in config.inicfg.keys()
1302+
and (
1303+
"--html=" in config.inicfg["addopts"]
1304+
or "--html " in config.inicfg["addopts"]
1305+
)
1306+
)
1307+
):
12871308
sb_config._using_html_report = True
12881309
sb_config._html_report_name = config.getoption("htmlpath")
12891310
if sb_config.dashboard:
12901311
if sb_config._html_report_name == "dashboard.html":
12911312
sb_config._dash_is_html_report = True
12921313

1314+
# Recorder Mode does not support multi-threaded / multi-process runs.
1315+
if sb_config.recorder_mode and sb_config._multithreaded:
1316+
# At this point, the user likely put a "-n NUM" in the pytest.ini file.
1317+
# Since raising an exception in pytest_configure raises INTERNALERROR,
1318+
# print a message here instead and cancel Recorder Mode.
1319+
print(
1320+
"\n Recorder Mode does NOT support multi-process mode (-n)!"
1321+
'\n (DO NOT combine "--recorder" with "-n NUM_PROCESSES"!)'
1322+
'\n (The Recorder WILL BE DISABLED during this run!)\n'
1323+
)
1324+
sb_config.recorder_mode = False
1325+
sb_config.recorder_ext = False
1326+
12931327
if sb_config.xvfb and "linux" not in sys.platform:
12941328
# The Xvfb virtual display server is for Linux OS Only!
12951329
sb_config.xvfb = False

0 commit comments

Comments
 (0)