Remove deprecated `-k foobar:` syntax
This commit is contained in:
parent
927d9d274f
commit
4a45a5e983
|
@ -37,11 +37,6 @@ YIELD_FIXTURE = PytestDeprecationWarning(
|
|||
"Use @pytest.fixture instead; they are the same."
|
||||
)
|
||||
|
||||
MINUS_K_COLON = PytestRemovedIn7Warning(
|
||||
"The `-k 'expr:'` syntax to -k is deprecated.\n"
|
||||
"Please open an issue if you use this and want a replacement."
|
||||
)
|
||||
|
||||
WARNING_CMDLINE_PREPARSE_HOOK = PytestRemovedIn8Warning(
|
||||
"The pytest_cmdline_preparse hook is deprecated and will be removed in a future release. \n"
|
||||
"Please use pytest_load_initial_conftests hook instead."
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Generic mechanism for marking and selecting python functions."""
|
||||
import warnings
|
||||
from typing import AbstractSet
|
||||
from typing import Collection
|
||||
from typing import List
|
||||
|
@ -23,7 +22,6 @@ from _pytest.config import ExitCode
|
|||
from _pytest.config import hookimpl
|
||||
from _pytest.config import UsageError
|
||||
from _pytest.config.argparsing import Parser
|
||||
from _pytest.deprecated import MINUS_K_COLON
|
||||
from _pytest.stash import StashKey
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -188,23 +186,14 @@ def deselect_by_keyword(items: "List[Item]", config: Config) -> None:
|
|||
if not keywordexpr:
|
||||
return
|
||||
|
||||
selectuntil = False
|
||||
if keywordexpr[-1:] == ":":
|
||||
# To be removed in pytest 8.0.0.
|
||||
warnings.warn(MINUS_K_COLON, stacklevel=2)
|
||||
selectuntil = True
|
||||
keywordexpr = keywordexpr[:-1]
|
||||
|
||||
expr = _parse_expression(keywordexpr, "Wrong expression passed to '-k'")
|
||||
|
||||
remaining = []
|
||||
deselected = []
|
||||
for colitem in items:
|
||||
if keywordexpr and not expr.evaluate(KeywordMatcher.from_item(colitem)):
|
||||
if not expr.evaluate(KeywordMatcher.from_item(colitem)):
|
||||
deselected.append(colitem)
|
||||
else:
|
||||
if selectuntil:
|
||||
keywordexpr = None
|
||||
remaining.append(colitem)
|
||||
|
||||
if deselected:
|
||||
|
|
|
@ -27,18 +27,6 @@ def test_external_plugins_integrated(pytester: Pytester, plugin) -> None:
|
|||
pytester.parseconfig("-p", plugin)
|
||||
|
||||
|
||||
def test_minus_k_colon_is_deprecated(pytester: Pytester) -> None:
|
||||
threepass = pytester.makepyfile(
|
||||
test_threepass="""
|
||||
def test_one(): assert 1
|
||||
def test_two(): assert 1
|
||||
def test_three(): assert 1
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest("-k", "test_two:", threepass)
|
||||
result.stdout.fnmatch_lines(["*The `-k 'expr:'` syntax*deprecated*"])
|
||||
|
||||
|
||||
def test_fscollector_gethookproxy_isinitpath(pytester: Pytester) -> None:
|
||||
module = pytester.getmodulecol(
|
||||
"""
|
||||
|
|
|
@ -823,25 +823,6 @@ class TestKeywordSelection:
|
|||
assert len(dlist) == 1
|
||||
assert dlist[0].items[0].name == "test_1"
|
||||
|
||||
def test_select_starton(self, pytester: Pytester) -> None:
|
||||
threepass = pytester.makepyfile(
|
||||
test_threepass="""
|
||||
def test_one(): assert 1
|
||||
def test_two(): assert 1
|
||||
def test_three(): assert 1
|
||||
"""
|
||||
)
|
||||
reprec = pytester.inline_run(
|
||||
"-Wignore::pytest.PytestRemovedIn7Warning", "-k", "test_two:", threepass
|
||||
)
|
||||
passed, skipped, failed = reprec.listoutcomes()
|
||||
assert len(passed) == 2
|
||||
assert not failed
|
||||
dlist = reprec.getcalls("pytest_deselected")
|
||||
assert len(dlist) == 1
|
||||
item = dlist[0].items[0]
|
||||
assert item.name == "test_one"
|
||||
|
||||
def test_keyword_extra(self, pytester: Pytester) -> None:
|
||||
p = pytester.makepyfile(
|
||||
"""
|
||||
|
|
|
@ -682,9 +682,7 @@ class TestTerminalFunctional:
|
|||
pass
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest(
|
||||
"-Wignore::pytest.PytestRemovedIn7Warning", "-k", "test_two:", testpath
|
||||
)
|
||||
result = pytester.runpytest("-k", "test_t", testpath)
|
||||
result.stdout.fnmatch_lines(
|
||||
["collected 3 items / 1 deselected / 2 selected", "*test_deselected.py ..*"]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue