-
-
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
Fix nodes._check_initialpaths_for_relpath for dirs #4352
Fix nodes._check_initialpaths_for_relpath for dirs #4352
Conversation
8baeb90
to
8532756
Compare
Codecov Report
@@ Coverage Diff @@
## master #4352 +/- ##
==========================================
+ Coverage 95.85% 95.85% +<.01%
==========================================
Files 111 111
Lines 24895 24907 +12
Branches 2431 2431
==========================================
+ Hits 23862 23874 +12
Misses 736 736
Partials 297 297
Continue to review full report at Codecov.
|
"*test_world.py::test_other*PASSED*", | ||
"*4 passed*", | ||
"test_hello.py::test_hello*PASSED*", | ||
"test_hello.py::test_other*PASSED*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this fix there was "hello/" here.
["*rootdir: {}/root, inifile:*".format(testdir.tmpdir), "*1 passed*"] | ||
[ | ||
"*rootdir: {}/root, inifile:*".format(testdir.tmpdir), | ||
"root/test_rootdir_option_arg.py *", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the fix this was root/test_rootdir_option_argX/test_rootdir_option_arg.py
.
src/_pytest/nodes.py
Outdated
@@ -447,6 +447,8 @@ def _prunetraceback(self, excinfo): | |||
def _check_initialpaths_for_relpath(session, fspath): | |||
for initial_path in session._initialpaths: | |||
if fspath.common(initial_path) == initial_path: | |||
if initial_path.isdir(): | |||
return fspath.relto(initial_path) | |||
return fspath.relto(initial_path.dirname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to codecov only the isdir
(new) path is covered: https://codecov.io/gh/pytest-dev/pytest/commit/8532756fe549edb6ecb01733f33f714cebdc35b2#D1-450
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And looking closer it shows that it can only really be a dir here, if it shares a / is the common path with fspath
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amended.
Ref: pytest-dev#4321 (comment) Hardens some of the not many tests affected by this: 1. `testing/test_session.py::test_rootdir_option_arg` displayed: > root/test_rootdir_option_arg2/test_rootdir_option_arg.py 2. `test_cmdline_python_namespace_package` displayed "hello/" prefix for: > hello/test_hello.py::test_hello > hello/test_hello.py::test_other
8532756
to
bee72a6
Compare
Ref: #4321 (comment)