-
-
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
problem collecting files with spaces in filename (regressed in 2.9.2 version) #1706
Comments
at first glance there seems to be something missing, its looking for a file called "A" there how exactly do you invoke/use pytest? |
The code to the plugin can be found here, In order to limit the tests that pytest can discover, I need to change directory (mostly inside subdirectory) before invoking pytest. I'm invoking pytest programmatically using multiprocessing.
|
The code you then post is not found on the link you posted... are you the plugin's author or an user?
|
Thanks a lot for looking into this issue! I'm the author of the plugin and I'd like to modify the plugin to cope with the new release of Pytest. There's a sample Jupyter Notebook that I uploaded here: I then summarized the steps to reproduce the issue using the above Jupyter Notebook here: |
@ldiary sorry but I didn't have time to test this yet. Meanwhile could you please test with pytest's |
I tried the latest features branch but it gave the same error:
|
I think I found the commit that introduced this regression:
The error happens inside |
Thanks for digging. I don't have time to dig into it right now, pinging @taschini if he wants to join the discussion. |
Okay, digging a little bit further, it turns out the code I mentioned above was not related (my apologies to @taschini). The When I checked the
In Pytest 2.9.1, While in Pytest 2.9.2, There's now an unnecessary quotation marks in the parsed result of Pytest 2.9.2; hence the error, |
Thanks for digging further. Do you have any idea of who's adding the unnecessary quotation marks? |
I think it's the other way around, 2.9.1 was able to remove the quotation marks while 2.9.2 did not bother to remove it during command line parsing. I had to pass the arguments in quotation marks just like below, because the filename has spaces in between.
|
Finally, I am now able to pinpoint the root cause. In 2.9.1, we have the following line of code in
In 2.9.2, this changed into the following due to #1523 and #1566:
When I tested on Windows 7, Windows 8 and Windows 10 machines... the
Using |
Hey @ldiary, thanks for pinpointing the cause! TBH I'm not sure anymore... I made a quick test here as well, and
But as commented here in #1554, apparently that was causing one of the tests on Windows to fail:
On this case passing |
Docs for the
|
It looks like we might need to consider the shlex.whitespace_split as previously mentioned by Rony on #1523 . I'll try to test other options later today. |
we should also consider going back on allowing the string, its demonstrating to be utterly error-prone the problems we see clearly show that there is no safe portable way to do this, we should consider leaving some conveniences out simply because correct implementation for us is riddled with a few days of work dragged over weeks due to finding platform incompatibilities one after another the more this piles up problems, the more im thinking that we want an api to call into pytest that can pass options properly pythonic instead of mushed strings |
Hmm actually I was thinking the same, it seems like a good intended minor convenience that proved to be more complicated/error prone than initially thought. We could then make an error passing strings to @ldiary how do you feel about this?
That's seems like a good idea... something like: retcode = pytest.main(args=['path/to/tests', '-k', 'match', 'x']) Something: outcome = pytest.run(paths=['path/to/tests'], k='match', exitfirst=True)
outcome.tests # list of "test nodes"
outcome.success # bool
outcome.failure # bool
# etc This would make easy to integrate pytest into scripts which need to call pytest and actually do something with the results. |
The last suggestion seems also simple to implement on top of the existing mechanisms |
@nicoddemus if we have pytest.run that would be super cool. The actual use cases I have right now are:
The I always encounter a problem using |
@ldiary I see, but can you change your code to pass a list of strings instead of a single string? This way we can remove support for passing a single string to |
@nicoddemus I've modified my code to pass a list of strings as you've suggested. And it looks like it is also the perfect workaround for this I'm happy to close this issue now (assuming you can re-open it should you wish to). |
Thanks! This form is deprecated now. 😁 |
I have this code working in pytest 2.9.1 version:
After the 2.9.2 release, the same code no longer works:
Perhaps related to what the change log says:
"Fix win32 path issue when puttinging custom config file with absolute path in pytest.main("-c your_absolute_path")."
But I don't know yet which commit to look at and how to figure a workaround on this.
The text was updated successfully, but these errors were encountered: