diff --git a/CHANGELOG b/CHANGELOG index 8034b55cd..559783681 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,8 @@ Changes between 2.3.3 and 2.3.4.dev ----------------------------------- - fix issue91 - add/discuss package/directory level setups in example +- allow to dynamically define markers/keywords via + item.keywords[...]=assignment Changes between 2.3.2 and 2.3.3 ----------------------------------- diff --git a/_pytest/__init__.py b/_pytest/__init__.py index cd0dc64e4..a02f81d00 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.4.dev1' +__version__ = '2.3.4.dev2' diff --git a/_pytest/mark.py b/_pytest/mark.py index af3f135ec..adcc14259 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -73,7 +73,7 @@ class BoolDict: return name in self._mydict def matchmark(colitem, matchexpr): - return eval(matchexpr, {}, BoolDict(colitem.obj.__dict__)) + return eval(matchexpr, {}, BoolDict(colitem.keywords)) def pytest_configure(config): if config.option.strict: diff --git a/setup.py b/setup.py index b16bc946a..5047bf89e 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.4.dev1', + version='2.3.4.dev2', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_mark.py b/testing/test_mark.py index 4fc3199ad..2f0884eeb 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -137,6 +137,30 @@ def test_mark_option(spec, testdir): assert len(passed) == len(passed_result) assert list(passed) == list(passed_result) +@pytest.mark.multi(spec=[ + ("interface", ("test_interface",)), + ("not interface", ("test_nointer",)), +]) +def test_mark_option_custom(spec, testdir): + testdir.makeconftest(""" + import pytest + def pytest_collection_modifyitems(items): + for item in items: + if "interface" in item.nodeid: + item.keywords["interface"] = pytest.mark.interface + """) + testdir.makepyfile(""" + def test_interface(): + pass + def test_nointer(): + pass + """) + opt, passed_result = spec + rec = testdir.inline_run("-m", opt) + passed, skipped, fail = rec.listoutcomes() + passed = [x.nodeid.split("::")[-1] for x in passed] + assert len(passed) == len(passed_result) + assert list(passed) == list(passed_result) class TestFunctional: @@ -386,7 +410,6 @@ class TestKeywordSelection: item = dlist[0].items[0] assert item.name == "test_one" - def test_keyword_extra(self, testdir): p = testdir.makepyfile(""" def test_one():