Fix nodes._check_initialpaths_for_relpath for dirs#4352
Fix nodes._check_initialpaths_for_relpath for dirs#4352blueyed merged 1 commit intopytest-dev:masterfrom
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.
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.
Before the fix this was root/test_rootdir_option_argX/test_rootdir_option_arg.py.
src/_pytest/nodes.py
Outdated
| 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.
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.
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?
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)