-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
When "Dynamically adding command line options" is added, pytest doesn't collect any tests #3302
Comments
GitMate.io thinks possibly related issues are #1150 (Pass dinamically command line option into a test body), #1123 (does pytest support to this way to collect test cases?), #654 (add pass rate option to pytest), #78 (pytest_addoption - Command-line options not added), and #532 (pytest -f does not notice new tests). |
i just made your output readable, and its clearly collected 2 tests that failed using different devices - please describe what you expected to see, because what i see is exactly what i would expect |
To get the 2 test collected, I have to comment out "args[:] = ["-n", str(num)] + args", and pass -n2 as the command line option with pytest invocation. See the first command line output, no tests were collected when the -n2 is added to pytest_cmdline_preparse(). |
@assundaram i missed the part in between since your formatting was so messed, let me fix up the original comment again |
@assundaram the problem is that you are adding You can add def pytest_cmdline_preparse(config, args):
worker = os.environ.get('PYTEST_XDIST_WORKER')
if 'xdist' in sys.modules and not worker: # pytest-xdist plugin
num = 2
args[:] = args + ["-n" + str(num)] Unfortunately you cannot use the |
@nicoddemus Thanks, that resolved the issue. pytest documentation needs to be updated. |
OK thanks for the feedback @assundaram, could you open a new issue with a proposal addition to the docs, or even a PR if you have the time? Thanks, appreciate it! |
Followed the pytest documentation for "Dynamically adding command line options"
Below is the sample code and command line output.
Contents of conftest.py:
Contents of test_parallel.py:
Command Line output of
pytest
:When I comment the args[:] line in conftest.py and pass the -n2 in command line, things work fine.
Command Line output of
pytest -n2
:The text was updated successfully, but these errors were encountered: