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

Do not include the root session with -k #7046

Merged
merged 2 commits into from
May 19, 2020

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Apr 8, 2020

Fixes #7040.

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The issue definitely seems like something that needs fixing, I'm not confident enough to evaluate whether this is the best solution though - hopefully others will chime in)

@@ -46,7 +46,7 @@ def from_item(cls, item: "Item") -> "KeywordMapping":
import pytest

for item in item.listchain():
if not isinstance(item, pytest.Instance):
if item.parent and not isinstance(item, pytest.Instance):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is item.parent the canonical way to check for the root node? And are we sure we always want to exclude the root node from keyword matching?

In any case a comment explaining the item.parent condition would be helpful I think since it's not immediately obvious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the previous fix is better, because it explicitly skips Session in the code. 👍

@nicoddemus nicoddemus added needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch and removed needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch labels May 16, 2020
@nicoddemus nicoddemus requested a review from bluetech May 16, 2020 17:06
assert_test_is_not_selected("+")
assert_test_is_not_selected("..")
# should not match against session
assert_test_is_not_selected(testdir.tmpdir.basename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to remove parametrization because of this one.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold up, the fix is not correct yet.

@RonnyPfannschmidt
Copy link
Member

This one should go in, and it classifies as breaking

Previously it contained the entire path, which made '-k' match
against any name in the full path of the package.

Fix pytest-dev#7040
@@ -568,8 +568,7 @@ def __init__(
nodes.FSCollector.__init__(
self, fspath, parent=parent, config=config, session=session, nodeid=nodeid
)

self.name = fspath.dirname
self.name = os.path.basename(str(fspath.dirname))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that one looks like a breaking change in isolation, does it bring us in line with other details or is it a new difference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crosschecked, it brings us in line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expressions match against folder structure above pytest root
4 participants