fix #4649 - also transfer markers to keywordmapping
as it turns out it is distinct from nodekeywords and behaves completely different
This commit is contained in:
parent
6154a5ac02
commit
f28b834426
|
@ -0,0 +1 @@
|
||||||
|
Restore marks being considered keywords for keyword expressions.
|
|
@ -45,13 +45,14 @@ class KeywordMapping(object):
|
||||||
mapped_names.add(item.name)
|
mapped_names.add(item.name)
|
||||||
|
|
||||||
# Add the names added as extra keywords to current or parent items
|
# Add the names added as extra keywords to current or parent items
|
||||||
for name in item.listextrakeywords():
|
mapped_names.update(item.listextrakeywords())
|
||||||
mapped_names.add(name)
|
|
||||||
|
|
||||||
# Add the names attached to the current function through direct assignment
|
# Add the names attached to the current function through direct assignment
|
||||||
if hasattr(item, "function"):
|
if hasattr(item, "function"):
|
||||||
for name in item.function.__dict__:
|
mapped_names.update(item.function.__dict__)
|
||||||
mapped_names.add(name)
|
|
||||||
|
# add the markers to the keywords as we no longer handle them correctly
|
||||||
|
mapped_names.update(mark.name for mark in item.iter_markers())
|
||||||
|
|
||||||
return cls(mapped_names)
|
return cls(mapped_names)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.foo
|
||||||
|
def test_mark():
|
||||||
|
pass
|
|
@ -292,6 +292,13 @@ def test_keyword_option_custom(spec, testdir):
|
||||||
assert list(passed) == list(passed_result)
|
assert list(passed) == list(passed_result)
|
||||||
|
|
||||||
|
|
||||||
|
def test_keyword_option_considers_mark(testdir):
|
||||||
|
testdir.copy_example("marks/marks_considered_keywords")
|
||||||
|
rec = testdir.inline_run("-k", "foo")
|
||||||
|
passed = rec.listoutcomes()[0]
|
||||||
|
assert len(passed) == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"spec",
|
"spec",
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue