Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #4649 - also transfer markers to keywordmapping #4655

Merged
merged 1 commit into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/4649.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restore marks being considered keywords for keyword expressions.
9 changes: 5 additions & 4 deletions src/_pytest/mark/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ def from_item(cls, item):
mapped_names.add(item.name)

# Add the names added as extra keywords to current or parent items
for name in item.listextrakeywords():
mapped_names.add(name)
mapped_names.update(item.listextrakeywords())

# Add the names attached to the current function through direct assignment
if hasattr(item, "function"):
for name in item.function.__dict__:
mapped_names.add(name)
mapped_names.update(item.function.__dict__)

# 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)

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest


@pytest.mark.foo
def test_mark():
pass
7 changes: 7 additions & 0 deletions testing/test_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ def test_pass():
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(
"spec",
[
Expand Down