2 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/d98f7495d1c7/ Changeset: d98f7495d1c7 Branch: multi-marks User: jameslan Date: 2013-11-02 05:10:13 Summary: Support multiple marks for individual parametrized argument set Affected #: 2 files
diff -r 8e65b5b17d12942193881ddcb9a244bc470a6fff -r d98f7495d1c7354f1582f82dd1c56d38475c56fe _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -693,16 +693,17 @@ 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 -r 8e65b5b17d12942193881ddcb9a244bc470a6fff -r d98f7495d1c7354f1582f82dd1c56d38475c56fe testing/python/collect.py --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -355,6 +355,21 @@ 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 https://bitbucket.org/hpk42/pytest/commits/ef5799b1bfe5/ Changeset: ef5799b1bfe5 User: hpk42 Date: 2013-11-02 07:02:28 Summary: Merged in jameslan/pytest/multi-marks (pull request #79) Support multiple marks for individual parametrized argument set Affected #: 2 files diff -r 8e65b5b17d12942193881ddcb9a244bc470a6fff -r ef5799b1bfe5f7d15224e7471a0ab02a92c8c351 _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -693,16 +693,17 @@ 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 -r 8e65b5b17d12942193881ddcb9a244bc470a6fff -r ef5799b1bfe5f7d15224e7471a0ab02a92c8c351 testing/python/collect.py --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -355,6 +355,21 @@ 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 Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit