Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error message when --dist worksteal, -n0 and --pdb flags are all set. #999

Open
3 of 4 tasks
superosku opened this issue Jan 4, 2024 · 1 comment
Open
3 of 4 tasks

Comments

@superosku
Copy link

Pytest shows an unexpected error message with the following flags:

 $ py.test -n0 --pdb --dist worksteal
ERROR: --pdb is incompatible with distributing tests; try using -n0 or -nauto.

This is an issue for me since I have a pytest.ini set up like so:

[pytest]
addopts =
  -n auto --dist worksteal

This allows me to have it so that the default pytest run without parameters runs all of the test in parallel mode in the most efficient way.

But quite often I run just one test file and when doing so I would like for pytest to not use the parallel mode so I add the -n0 flag. This works as expected. I can also run pytest with just the --pdb flag, this automatically disables the parallelism as well.

But when I have both the --pdb and -n0 flags I get the error.

Everything works as expected when --dist worksteal is not there in the pytest.ini file but that can make the full parallel test suite run slower than it needs to be.

This is a big issue for me since I often run tests on single test file many times over and I alternate between running it with pdb and without. It would be much more convininent and faster if I could just add and remove the --pdb flag instead of alternating between the --pdb and -n0 flags.

Also I think the error message describes the issue poorly since I already have the -n0 flag on that is suggested by it.

Thanks

Pytest version:

py.test --version
pytest 7.4.3

Operating system version:

macOS 13.6.1 (22G313)
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible
@RonnyPfannschmidt
Copy link
Member

this is rooted in

def pytest_cmdline_main(config):
usepdb = config.getoption("usepdb", False) # a core option
if config.option.numprocesses in ("auto", "logical"):
if usepdb:
config.option.numprocesses = 0
config.option.dist = "no"
else:
auto_num_cpus = config.hook.pytest_xdist_auto_num_workers(config=config)
config.option.numprocesses = auto_num_cpus
if config.option.numprocesses:
if config.option.dist == "no":
config.option.dist = "load"
numprocesses = config.option.numprocesses
if config.option.maxprocesses:
numprocesses = min(numprocesses, config.option.maxprocesses)
config.option.tx = ["popen"] * numprocesses
if config.option.distload:
config.option.dist = "load"
val = config.getvalue
if not val("collectonly") and val("dist") != "no" and usepdb:
raise pytest.UsageError(
"--pdb is incompatible with distributing tests; try using -n0 or -nauto."

it seeems like this edge-case is missed, moving the issue to xdist

@RonnyPfannschmidt RonnyPfannschmidt transferred this issue from pytest-dev/pytest Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants