@@ -27,10 +27,14 @@ def cpu_count():
2727 return n if n else 1
2828
2929
30+ class AutoInt (int ):
31+ """Mark value as auto-detected."""
32+
33+
3034def parse_numprocesses (s ):
3135 if s == "auto" :
32- return auto_detect_cpus ()
33- else :
36+ return AutoInt ( auto_detect_cpus () )
37+ elif s is not None :
3438 return int (s )
3539
3640
@@ -45,7 +49,7 @@ def pytest_addoption(parser):
4549 type = parse_numprocesses ,
4650 help = "shortcut for '--dist=load --tx=NUM*popen', "
4751 "you can use 'auto' here for auto detection CPUs number on "
48- "host system" ,
52+ "host system and it will be 0 when used with --pdb " ,
4953 )
5054 group .addoption (
5155 "--maxprocesses" ,
@@ -177,6 +181,10 @@ def pytest_configure(config):
177181
178182@pytest .mark .tryfirst
179183def pytest_cmdline_main (config ):
184+ usepdb = config .getoption ("usepdb" ) # a core option
185+ if isinstance (config .option .numprocesses , AutoInt ):
186+ config .option .numprocesses = 0 if usepdb else int (config .option .numprocesses )
187+
180188 if config .option .numprocesses :
181189 if config .option .dist == "no" :
182190 config .option .dist = "load"
@@ -188,11 +196,10 @@ def pytest_cmdline_main(config):
188196 config .option .dist = "load"
189197 val = config .getvalue
190198 if not val ("collectonly" ):
191- usepdb = config .getoption ("usepdb" ) # a core option
192199 if val ("dist" ) != "no" :
193200 if usepdb :
194201 raise pytest .UsageError (
195- "--pdb is incompatible with distributing tests; try using -n0."
202+ "--pdb is incompatible with distributing tests; try using -n0 or -nauto ."
196203 ) # noqa: E501
197204
198205
0 commit comments