Added a test to check there is no matching on magic values.

This commit is contained in:
Wouter van Ackooy 2013-05-23 09:12:50 +02:00
parent 02511d1564
commit 583c736f0c
1 changed files with 18 additions and 0 deletions

View File

@ -439,3 +439,21 @@ class TestKeywordSelection:
reprec = testdir.inline_run("-k", "mykeyword", p)
passed, skipped, failed = reprec.countoutcomes()
assert failed == 1
def test_no_magic_values(self, testdir):
"""Make sure the tests do not match on magic values,
no double underscored values, like '__dict__',
and no instance values, like '()'.
"""
p = testdir.makepyfile("""
def test_one(): assert 1
""")
def assert_test_is_not_selected(keyword):
reprec = testdir.inline_run("-k", keyword, p)
passed, skipped, failed = reprec.countoutcomes()
dlist = reprec.getcalls("pytest_deselected")
assert passed + skipped + failed == 0
assert len(dlist) == 1
assert_test_is_not_selected("__")
assert_test_is_not_selected("()")