allow to dynamically define markers (e.g. during pytest_collection_modifyitems)
This commit is contained in:
parent
c790490387
commit
a4909a0ae4
|
@ -2,6 +2,8 @@ Changes between 2.3.3 and 2.3.4.dev
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
- fix issue91 - add/discuss package/directory level setups in example
|
- 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
|
Changes between 2.3.2 and 2.3.3
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#
|
#
|
||||||
__version__ = '2.3.4.dev1'
|
__version__ = '2.3.4.dev2'
|
||||||
|
|
|
@ -73,7 +73,7 @@ class BoolDict:
|
||||||
return name in self._mydict
|
return name in self._mydict
|
||||||
|
|
||||||
def matchmark(colitem, matchexpr):
|
def matchmark(colitem, matchexpr):
|
||||||
return eval(matchexpr, {}, BoolDict(colitem.obj.__dict__))
|
return eval(matchexpr, {}, BoolDict(colitem.keywords))
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
if config.option.strict:
|
if config.option.strict:
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -48,7 +48,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.3.4.dev1',
|
version='2.3.4.dev2',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
|
@ -137,6 +137,30 @@ def test_mark_option(spec, testdir):
|
||||||
assert len(passed) == len(passed_result)
|
assert len(passed) == len(passed_result)
|
||||||
assert list(passed) == list(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:
|
class TestFunctional:
|
||||||
|
|
||||||
|
@ -386,7 +410,6 @@ class TestKeywordSelection:
|
||||||
item = dlist[0].items[0]
|
item = dlist[0].items[0]
|
||||||
assert item.name == "test_one"
|
assert item.name == "test_one"
|
||||||
|
|
||||||
|
|
||||||
def test_keyword_extra(self, testdir):
|
def test_keyword_extra(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
def test_one():
|
def test_one():
|
||||||
|
|
Loading…
Reference in New Issue