summaryrefslogtreecommitdiff
path: root/testing/deprecated_test.py
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2020-05-11 15:44:01 +0300
committerRan Benita <ran@unusedvar.com>2020-05-11 16:07:52 +0300
commitc4f9eaa5de7db6dc23e4f8296f3504a8d684fca0 (patch)
treef7a12ff1c0988ecf8d4d0d4b3dd12f2a6f3d3c9c /testing/deprecated_test.py
parent5e7f1ab4bf58e473e5d7f878eb2b499d7deabd29 (diff)
downloadpytest-c4f9eaa5de7db6dc23e4f8296f3504a8d684fca0.tar.gz
mark: deprecate a couple undocumented -k syntaxes
The `-k '-expr'` syntax is an old alias to `-k 'not expr'`. It's also not a very convenient to have syntax that start with `-` on the CLI. Deprecate it and suggest replacing with `not`. --- The `-k 'expr:'` syntax discards all items until the first match and keeps all subsequent, e.g. `-k foo` with test_bar test_foo test_baz results in `test_foo`, `test_baz`. That's a bit weird, so deprecate it without a replacement. If someone complains we can reconsider or devise a better alternative.
Diffstat (limited to 'testing/deprecated_test.py')
-rw-r--r--testing/deprecated_test.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py
index 5ad055bd2..edd5505c0 100644
--- a/testing/deprecated_test.py
+++ b/testing/deprecated_test.py
@@ -164,3 +164,27 @@ def test__fillfuncargs_is_deprecated() -> None:
match="The `_fillfuncargs` function is deprecated",
):
pytest._fillfuncargs(mock.Mock())
+
+
+def test_minus_k_dash_is_deprecated(testdir) -> None:
+ threepass = testdir.makepyfile(
+ test_threepass="""
+ def test_one(): assert 1
+ def test_two(): assert 1
+ def test_three(): assert 1
+ """
+ )
+ result = testdir.runpytest("-k=-test_two", threepass)
+ result.stdout.fnmatch_lines(["*The `-k '-expr'` syntax*deprecated*"])
+
+
+def test_minus_k_colon_is_deprecated(testdir) -> None:
+ threepass = testdir.makepyfile(
+ test_threepass="""
+ def test_one(): assert 1
+ def test_two(): assert 1
+ def test_three(): assert 1
+ """
+ )
+ result = testdir.runpytest("-k", "test_two:", threepass)
+ result.stdout.fnmatch_lines(["*The `-k 'expr:'` syntax*deprecated*"])