[Pytest-commit] commit/pytest: hpk42: fix issue557: with "-k" we only allow the old style "-" for negation
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Oct 6 12:12:04 CEST 2014
1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/commits/6d407ed022d7/
Changeset: 6d407ed022d7
Branch: issue557
User: hpk42
Date: 2014-10-06 10:11:48+00:00
Summary: fix issue557: with "-k" we only allow the old style "-" for negation
at the beginning of strings and even that is deprecated. Use "not" instead.
This should allow to pick parametrized tests where "-" appeared in the parameter.
Affected #: 3 files
diff -r 31668a78f211ce8e782c8b838a16185625f1ccb0 -r 6d407ed022d75e4addc1084a7bd53d04b146cda3 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,10 @@
- updated plugin index docs. Thanks Bruno Oliveira.
+- fix issue557: with "-k" we only allow the old style "-" for negation
+ at the beginning of strings and even that is deprecated. Use "not" instead.
+ This should allow to pick parametrized tests where "-" appeared in the parameter.
+
2.6.3
-----------
diff -r 31668a78f211ce8e782c8b838a16185625f1ccb0 -r 6d407ed022d75e4addc1084a7bd53d04b146cda3 _pytest/mark.py
--- a/_pytest/mark.py
+++ b/_pytest/mark.py
@@ -56,6 +56,11 @@
matchexpr = config.option.markexpr
if not keywordexpr and not matchexpr:
return
+ # pytest used to allow "-" for negating
+ # but today we just allow "-" at the beginning, use "not" instead
+ # we probably remove "-" alltogether soon
+ if keywordexpr.startswith("-"):
+ keywordexpr = "not " + keywordexpr[1:]
selectuntil = False
if keywordexpr[-1:] == ":":
selectuntil = True
@@ -122,7 +127,6 @@
Additionally, matches on names in the 'extra_keyword_matches' set of
any item, as well as names directly assigned to test functions.
"""
- keywordexpr = keywordexpr.replace("-", "not ")
mapped_names = set()
# Add the names of the current item and any parent items
diff -r 31668a78f211ce8e782c8b838a16185625f1ccb0 -r 6d407ed022d75e4addc1084a7bd53d04b146cda3 testing/test_mark.py
--- a/testing/test_mark.py
+++ b/testing/test_mark.py
@@ -234,12 +234,13 @@
@pytest.mark.parametrize("spec", [
("None", ("test_func[None]",)),
- ("1.3", ("test_func[1.3]",))
+ ("1.3", ("test_func[1.3]",)),
+ ("2-3", ("test_func[2-3]",))
])
def test_keyword_option_parametrize(spec, testdir):
testdir.makepyfile("""
import pytest
- @pytest.mark.parametrize("arg", [None, 1.3])
+ @pytest.mark.parametrize("arg", [None, 1.3, "2-3"])
def test_func(arg):
pass
""")
@@ -497,7 +498,7 @@
check('TestClass and test', 'test_method_one')
@pytest.mark.parametrize("keyword", [
- 'xxx', 'xxx and test_2', 'TestClass', 'xxx and -test_1',
+ 'xxx', 'xxx and test_2', 'TestClass', 'xxx and not test_1',
'TestClass and test_2', 'xxx and TestClass and test_2'])
def test_select_extra_keywords(self, testdir, keyword):
p = testdir.makepyfile(test_select="""
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list