Skip to content

Commit 4a45a5e

Browse files
committed
Remove deprecated -k foobar: syntax
1 parent 927d9d2 commit 4a45a5e

File tree

5 files changed

+2
-51
lines changed

5 files changed

+2
-51
lines changed

src/_pytest/deprecated.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
"Use @pytest.fixture instead; they are the same."
3838
)
3939

40-
MINUS_K_COLON = PytestRemovedIn7Warning(
41-
"The `-k 'expr:'` syntax to -k is deprecated.\n"
42-
"Please open an issue if you use this and want a replacement."
43-
)
44-
4540
WARNING_CMDLINE_PREPARSE_HOOK = PytestRemovedIn8Warning(
4641
"The pytest_cmdline_preparse hook is deprecated and will be removed in a future release. \n"
4742
"Please use pytest_load_initial_conftests hook instead."

src/_pytest/mark/__init__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Generic mechanism for marking and selecting python functions."""
2-
import warnings
32
from typing import AbstractSet
43
from typing import Collection
54
from typing import List
@@ -23,7 +22,6 @@
2322
from _pytest.config import hookimpl
2423
from _pytest.config import UsageError
2524
from _pytest.config.argparsing import Parser
26-
from _pytest.deprecated import MINUS_K_COLON
2725
from _pytest.stash import StashKey
2826

2927
if TYPE_CHECKING:
@@ -188,23 +186,14 @@ def deselect_by_keyword(items: "List[Item]", config: Config) -> None:
188186
if not keywordexpr:
189187
return
190188

191-
selectuntil = False
192-
if keywordexpr[-1:] == ":":
193-
# To be removed in pytest 8.0.0.
194-
warnings.warn(MINUS_K_COLON, stacklevel=2)
195-
selectuntil = True
196-
keywordexpr = keywordexpr[:-1]
197-
198189
expr = _parse_expression(keywordexpr, "Wrong expression passed to '-k'")
199190

200191
remaining = []
201192
deselected = []
202193
for colitem in items:
203-
if keywordexpr and not expr.evaluate(KeywordMatcher.from_item(colitem)):
194+
if not expr.evaluate(KeywordMatcher.from_item(colitem)):
204195
deselected.append(colitem)
205196
else:
206-
if selectuntil:
207-
keywordexpr = None
208197
remaining.append(colitem)
209198

210199
if deselected:

testing/deprecated_test.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ def test_external_plugins_integrated(pytester: Pytester, plugin) -> None:
2727
pytester.parseconfig("-p", plugin)
2828

2929

30-
def test_minus_k_colon_is_deprecated(pytester: Pytester) -> None:
31-
threepass = pytester.makepyfile(
32-
test_threepass="""
33-
def test_one(): assert 1
34-
def test_two(): assert 1
35-
def test_three(): assert 1
36-
"""
37-
)
38-
result = pytester.runpytest("-k", "test_two:", threepass)
39-
result.stdout.fnmatch_lines(["*The `-k 'expr:'` syntax*deprecated*"])
40-
41-
4230
def test_fscollector_gethookproxy_isinitpath(pytester: Pytester) -> None:
4331
module = pytester.getmodulecol(
4432
"""

testing/test_mark.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -823,25 +823,6 @@ def pytest_pycollect_makeitem(name):
823823
assert len(dlist) == 1
824824
assert dlist[0].items[0].name == "test_1"
825825

826-
def test_select_starton(self, pytester: Pytester) -> None:
827-
threepass = pytester.makepyfile(
828-
test_threepass="""
829-
def test_one(): assert 1
830-
def test_two(): assert 1
831-
def test_three(): assert 1
832-
"""
833-
)
834-
reprec = pytester.inline_run(
835-
"-Wignore::pytest.PytestRemovedIn7Warning", "-k", "test_two:", threepass
836-
)
837-
passed, skipped, failed = reprec.listoutcomes()
838-
assert len(passed) == 2
839-
assert not failed
840-
dlist = reprec.getcalls("pytest_deselected")
841-
assert len(dlist) == 1
842-
item = dlist[0].items[0]
843-
assert item.name == "test_one"
844-
845826
def test_keyword_extra(self, pytester: Pytester) -> None:
846827
p = pytester.makepyfile(
847828
"""

testing/test_terminal.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,7 @@ def test_three():
682682
pass
683683
"""
684684
)
685-
result = pytester.runpytest(
686-
"-Wignore::pytest.PytestRemovedIn7Warning", "-k", "test_two:", testpath
687-
)
685+
result = pytester.runpytest("-k", "test_t", testpath)
688686
result.stdout.fnmatch_lines(
689687
["collected 3 items / 1 deselected / 2 selected", "*test_deselected.py ..*"]
690688
)

0 commit comments

Comments
 (0)