Skip to content

Cannot use "pytest test_*" (with wildchar filter) to collect cases on Windows 7 command line #6971

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

Open
chenzx opened this issue Mar 26, 2020 · 8 comments
Labels
topic: collection related to the collection phase type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@chenzx
Copy link

chenzx commented Mar 26, 2020

"pytest test_*" cmd lets me selectively run specific tests which are classified by filename prefixes
this works on my mac perfectly
but when i try the trick on a windows 7 machines, pytest cannot collect any cases.

@RonnyPfannschmidt
Copy link
Member

at first glance i strongly suspect this is a shell issue
in mac its likely that bash (i hope thats correct, i use linux)just expands test_* to a number of filenames

im not aware about how the shells on windows manage it,
my understanding is, that on windows, the programs are supposed to expand wildcards, which pytest currently does not do

adding passed wild-card expansion would be a new feature,
if only support foor * expansion is added,
i believe it wouldn't be a breaking change

in that case its a help wanted item

@The-Compiler
Copy link
Member

Pretty much what @RonnyPfannschmidt says - also see e.g. psf/black#1198 and pallets/click#1096.

Note that if pytest did that kind of expansion, it should be done on Windows only.

@RonnyPfannschmidt
Copy link
Member

i believe support on all platforms is possibly sensible, as it would allow wildcard support in PYTEST_ADDOPTS and the addopts option

@Zac-HD
Copy link
Member

Zac-HD commented Mar 26, 2020

The problem with expanding wildcards is that it's possible to have a file literally named test_* that you want to run pytest on, and then what?

Shells all have a way to disable wildcard expansion one-by-one for this reason, which I really don't want to duplicate in pytest.

@Zac-HD Zac-HD added topic: collection related to the collection phase type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature labels Mar 26, 2020
@The-Compiler
Copy link
Member

The problem with expanding wildcards is that it's possible to have a file literally named test_* that you want to run pytest on, and then what?

That isn't possible on Windows - hence my proposal to only do the expansion on Windows. Yes, that means there's no way to use wildcards in PYTEST_ADDOPTS and addopts, but I can't think of a good reason to use them there to be honest.

@RonnyPfannschmidt
Copy link
Member

Good point, we should have a option to control the behaviour with sane defaults for posix vs windows

@harishkesavarao
Copy link

harishkesavarao commented Nov 23, 2023

@RonnyPfannschmidt @The-Compiler Has this been fixed via #1830?

@RonnyPfannschmidt
Copy link
Member

The linked issue it's about raises?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: collection related to the collection phase type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

5 participants