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 #3751 #3798
Fix #3751 #3798
Conversation
testing/test_collection.py
Outdated
@@ -647,7 +647,7 @@ def test_pkgfile(self, testdir): | |||
col = testdir.getnode(config, x) | |||
assert isinstance(col, pytest.Module) | |||
assert col.name == "x.py" | |||
assert col.parent.parent is None | |||
assert col.parent.parent.parent is None |
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.
lets please add add comment here to explain the nesting since it is a tad confusing as of now
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.
Agreed. Probably checking the name
of each parent will also help clarifying things. 👍
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.
It's pretty simple, it's basically testing to see that the Session's parent is None, which should always be and the nodes have been correctly nested. For a more visual example:
tmpdir
\- subdir
\- __init__.py
\- x.py
Session<>
^
| (parent)
Package<subdir>
^
| (parent)
Module<x>
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.
Maybe the ASCII diagram could be added to the test's docstring?
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.
Thanks @jonozzz!
Let's improve the test a bit before merging this
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.
Thanks for the comment @jonozzz.
I fixed the formatting (it was mixing tabs and spaces apparently) and also improved the test a bit.
assert isinstance(col, pytest.Module) | ||
assert isinstance(col.parent, pytest.Package) | ||
assert isinstance(col.parent.parent, pytest.Session) | ||
# session is batman (has no parents) |
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.
Lol 😂
@RonnyPfannschmidt and @blueyed you want to take more time to review this or can we merge it? |
The previous fix would basically bypass the if block because the return value would always be a list.