diff options
author | holger krekel <holger@merlinux.eu> | 2013-11-02 07:04:26 +0100 |
---|---|---|
committer | holger krekel <holger@merlinux.eu> | 2013-11-02 07:04:26 +0100 |
commit | a9d1f40c294e18c68ca27f03a4a8fd5614ec6298 (patch) | |
tree | 4d0ecbe297120260ca60b65055c7b49747315d77 | |
parent | f674c57d1a3511845ae0103dca552e34499c0685 (diff) | |
parent | e2d19aab39d880977077e8062ed3ebddaf8c1aaa (diff) | |
download | pytest-a9d1f40c294e18c68ca27f03a4a8fd5614ec6298.tar.gz |
merge, add changelog entry
-rw-r--r-- | CHANGELOG | 5 | ||||
-rw-r--r-- | _pytest/python.py | 9 | ||||
-rw-r--r-- | testing/python/collect.py | 15 |
3 files changed, 24 insertions, 5 deletions
@@ -1,6 +1,8 @@ -Changes between 2.4.2 and 2.4.3 +Unreleased ----------------------------------- +- allow nested parametrize-value markers, thanks James Lan for the PR. + - fix unicode handling with new monkeypatch.setattr(import_path, value) API. Thanks Rob Dennis. Fixes issue371. @@ -30,6 +32,7 @@ Changes between 2.4.2 and 2.4.3 arg is an lambda and thus the example will work. Thanks Alex Gaynor for bringing it up. + Changes between 2.4.1 and 2.4.2 ----------------------------------- diff --git a/_pytest/python.py b/_pytest/python.py index 9aa000588..4c742c668 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -693,16 +693,17 @@ class Metafunc(FuncargnamesCompatAttr): to set a dynamic scope using test context or configuration. """ - # individual parametrized argument sets can be wrapped in a - # marker in which case we unwrap the values and apply the mark + # individual parametrized argument sets can be wrapped in a series + # of markers in which case we unwrap the values and apply the mark # at Function init newkeywords = {} unwrapped_argvalues = [] for i, argval in enumerate(argvalues): - if isinstance(argval, MarkDecorator): + while isinstance(argval, MarkDecorator): newmark = MarkDecorator(argval.markname, argval.args[:-1], argval.kwargs) - newkeywords[i] = {newmark.markname: newmark} + newmarks = newkeywords.setdefault(i, {}) + newmarks[newmark.markname] = newmark argval = argval.args[-1] unwrapped_argvalues.append(argval) argvalues = unwrapped_argvalues diff --git a/testing/python/collect.py b/testing/python/collect.py index 5f7e33dfb..62ce6fc37 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -355,6 +355,21 @@ class TestFunction: rec = testdir.inline_run() rec.assertoutcome(passed=2) + def test_parametrize_with_mark(selfself, testdir): + items = testdir.getitems(""" + import pytest + @pytest.mark.foo + @pytest.mark.parametrize('arg', [ + 1, + pytest.mark.bar(pytest.mark.baz(2)) + ]) + def test_function(arg): + pass + """) + keywords = [item.keywords for item in items] + assert 'foo' in keywords[0] and 'bar' not in keywords[0] and 'baz' not in keywords[0] + assert 'foo' in keywords[1] and 'bar' in keywords[1] and 'baz' in keywords[1] + def test_function_equality_with_callspec(self, testdir, tmpdir): items = testdir.getitems(""" import pytest |