Skip to content
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

Fix pytest test filename path resolution #149

Merged
merged 1 commit into from
May 1, 2020

Conversation

StefRe
Copy link
Contributor

@StefRe StefRe commented Apr 23, 2020

Pytest test filenames are relative to the rootdir. This rootdir is not
necessarily the directory from which discovery starts, i.e. wdir from
spyder-unittest's config. For details on how pytest determins the rootdir see
Initialization: determining rootdir and inifile
Filenames used to be resolved against wdir. If wdir is not the rootdir (as
described in the above link) this resulted in invalid resolved filenames.
This commit gets the rootdir in the pytest_report_header hook which is
called after all configuration is done and before any test collection
starts. This rootdir is then used for filename path resolution.

This resolves #145

@StefRe
Copy link
Contributor Author

StefRe commented Apr 23, 2020

I just saw that the checks failed due to an internal server error: can you re-run them or shall I push a dummy commit to trigger the re-run (see How do I re-run Github Actions)?

@jitseniesen
Copy link
Member

I tried re-running them but there is something wrong with Actions according to the GitHub status page. I'll try again tomorrow.

@jitseniesen
Copy link
Member

The tests now work and pass. In the future, feel free to push empty commits.

Regarding toe code, it's a small patch which I like. My first thought was to compute the rootdir ourselves, but it is more robust to get it from pytest as you are doing.

It will probably be a few days before I can look at it in detail.

Pytest test filenames are relative to the rootdir. This rootdir is not
necessarily the directory from which discovery starts, i.e. wdir from
spyder-unittest's config. For details on how pytest determins the rootdir see
https://docs.pytest.org/en/latest/customize.html#initialization-determining-rootdir-and-inifile.
Filenames used to be resolved against wdir. If wdir is not the rootdir (as
described in the above link) this resulted in invalid resolved filenames.
This commit gets the rootdir in the pytest_report_header hook which is
called after all configuration is done and before any test collection
starts. This rootdir is then used for filename path resolution.
@codecov-io
Copy link

Codecov Report

Merging #149 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
spyder_unittest/backend/pytestrunner.py 97.80% <100.00%> (+0.04%) ⬆️
spyder_unittest/backend/pytestworker.py 94.87% <100.00%> (+0.13%) ⬆️

@StefRe
Copy link
Contributor Author

StefRe commented Apr 30, 2020

I rebased this PR onto the current master so that it again is mergeable now.

@jitseniesen
Copy link
Member

Thanks!

@jitseniesen jitseniesen merged commit 3c73e70 into spyder-ide:master May 1, 2020
@StefRe StefRe deleted the fix/filename branch May 1, 2020 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Go to test definition only works when run from root dir
3 participants