Skip to content

Commit 3d3b951

Browse files
blueyednicoddemus
authored andcommitted
-k should not match session name
Fixes #7040.
1 parent d4dfe86 commit 3d3b951

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

changelog/7040.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``-k`` no longer matches against the directory containing the test suite.

src/_pytest/mark/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def from_item(cls, item: "Item") -> "KeywordMatcher":
136136
import pytest
137137

138138
for item in item.listchain():
139-
if not isinstance(item, pytest.Instance):
139+
if not isinstance(item, (pytest.Instance, pytest.Session)):
140140
mapped_names.add(item.name)
141141

142142
# Add the names added as extra keywords to current or parent items

0 commit comments

Comments
 (0)