Change -k EXPRESSION matching to be case-insensitive
This commit is contained in:
parent
985ac09048
commit
e24b6b0388
|
@ -57,7 +57,15 @@ class KeywordMapping:
|
||||||
return cls(mapped_names)
|
return cls(mapped_names)
|
||||||
|
|
||||||
def __getitem__(self, subname):
|
def __getitem__(self, subname):
|
||||||
for name in self._names:
|
"""Return whether subname is included within stored names.
|
||||||
|
|
||||||
|
The string inclusion check is case-insensitive.
|
||||||
|
|
||||||
|
"""
|
||||||
|
subname = subname.lower()
|
||||||
|
names = [name.lower() for name in self._names]
|
||||||
|
|
||||||
|
for name in names:
|
||||||
if subname in name:
|
if subname in name:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -809,6 +809,40 @@ class TestNodekeywords:
|
||||||
reprec = testdir.inline_run("-k repr")
|
reprec = testdir.inline_run("-k repr")
|
||||||
reprec.assertoutcome(passed=1, failed=0)
|
reprec.assertoutcome(passed=1, failed=0)
|
||||||
|
|
||||||
|
def test_keyword_matching_is_case_insensitive_by_default(self, testdir):
|
||||||
|
"""Check that selection via -k EXPRESSION is case-insensitive.
|
||||||
|
|
||||||
|
Since markers are also added to the node keywords, they too can
|
||||||
|
be matched without having to think about case sensitivity.
|
||||||
|
|
||||||
|
"""
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
def test_sPeCiFiCToPiC_1():
|
||||||
|
assert True
|
||||||
|
|
||||||
|
class TestSpecificTopic_2:
|
||||||
|
def test(self):
|
||||||
|
assert True
|
||||||
|
|
||||||
|
@pytest.mark.sPeCiFiCToPic_3
|
||||||
|
def test():
|
||||||
|
assert True
|
||||||
|
|
||||||
|
@pytest.mark.sPeCiFiCToPic_4
|
||||||
|
class Test:
|
||||||
|
def test(self):
|
||||||
|
assert True
|
||||||
|
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
num_all_tests_passed = 4
|
||||||
|
for expression in ("specifictopic", "SPECIFICTOPIC", "SpecificTopic"):
|
||||||
|
reprec = testdir.inline_run("-k " + expression)
|
||||||
|
reprec.assertoutcome(passed=num_all_tests_passed, failed=0)
|
||||||
|
|
||||||
|
|
||||||
COLLECTION_ERROR_PY_FILES = dict(
|
COLLECTION_ERROR_PY_FILES = dict(
|
||||||
test_01_failure="""
|
test_01_failure="""
|
||||||
|
|
Loading…
Reference in New Issue