-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Test assertions does not work properly when specifying python_files setting #2121
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
Comments
Thanks @nip3o for the report and taking the time to produce a reproducible example repository. |
I had the same problem, files matched from a directory do not get their errors rewritten. I'm no expert, but I think it has to do with what is matched when searching for files and catching their exceptions. |
Thanks to @nip3o example repository I've created a test case that shows this bug in PR #2140. When Would it be possible to delay the fetching of @flub Do you have any idea on this? :) |
Thanks @pelme! Looking at https://github.com/pytest-dev/pytest/blob/master/_pytest/assertion/rewrite.py#L51, it seems we could just initialize it with I can take a look when I have some time (perhaps this weekend), but feel free to try it yourself in #2140 if you find the time. 🙇 |
Good suggestion Bruno! :) However, calling |
Uh oh, then I'm afraid the fix is more complicated than I was expecting, because |
I did a bit of digging, here is what I found:
I'll continue to and see if I can work around the issue and use pys fnmatch somehow. :) |
I've tracked down the root cause:
However, the issue with just doing Here is the relevant line in py: Here is a PR to With that PR, we can just use |
python_files handled properly when rewriting assertions.
If anyone wants to try this out before it gets merged/released, you can install py and pytest from git:
|
Thanks @pelme! I didn't realize that |
python_files handled properly when rewriting assertions.
The user-friendly error messages when test assertion fails in seems to be broken in certain situations. I have created a minimal example project to illustrate this: https://github.com/nip3o/pytest-assert-rewrite-example
When
python_files
setting is not set, or when the full path to the test file is specified, assertion rewrite works as expectedWhen adding a
python_files
setting to pytest.ini, and not specifying the full path to the test file, assertion rewrite does not work.Tested in multiple projects with pytest 3.0.3 as well as 3.0.5. I have included the full output from test runs with debug mode in the repository above.
The text was updated successfully, but these errors were encountered: