-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Proposing a new flag, --list-of-files-or-dirs
, to compliment the positional file_or_dir
argument
#11871
Comments
Can you talk a bit more about your use-case? Why are you passing such a long list of files in the first place? |
We're looking into dynamically choosing which tests to run for a given PR as part of our CI run. The output of this test selection would be a list of tests from our test suite to run. The list is 0...N, and although this is discouraged, N theoretically could be hundreds of tests long if the PR is big / touches many files and functions. |
i would recommend using a collect_ignore hook then instead of needing a new pytest feature and new pytest release, you can simply ignore/remove unwanted tests from collection either before collecting a file, or after collection completed |
The new file I'm proposing is a standalone, brand new file generated for the sake of CI alone, and so would not have any effect on existing code. Moreover, If we do go with this approach, we would need to first collect all our existing tests, and then deduct the list of tests we want to run, push that to |
@jbkkd Your use case makes sense, but I'm not clear why you need a file for this instead of passing the arguments on the command line as usual. That is, instead of There is a convention of using
The use case I'm familiar with is command line max length issues on Windows. |
I would like to add that the I think there are legitimate uses for this feature (in some form or another), plus it is simple to implement, we should consider adding it to pytest. |
https://docs.python.org/3/library/argparse.html#fromfile-prefix-chars It's possible that it constitutes a breaking change, just very unlikely |
I think using |
Just want to point out that it would be nice if the contents of the file could be the output of |
thats how the |
What's the problem this feature will solve?
Passing a long list of test files/dirs into the pytest CLI can make reading the pytest command confusing.
Describe the solution you'd like
A new flag,
--list-of-files-or-dirs
, to compliment the positionalfile_or_dir
argument.The new flag will accept a single text file, with each line in the file representing a positional argument to pytest.
So, instead of calling pytest like this:
pytest test_file1.py test_file2.py test_file3.py ...
One would call:
pytest --list-of-files-or-dirs list_file.txt
With
list_file.txt
containing:Alternative Solutions
You can currently just call pytest with a list of all the files/dirs you want to test, but a long list passed through the CLI isn't such a clean interface.
Additional context
Happy to work take a stab at working on this if there's consensus that such a PR would be accepted.
The text was updated successfully, but these errors were encountered: