diff --git a/CHANGELOG b/CHANGELOG index beabc5741..e82bf4673 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ 2.8.0.dev (compared to 2.7.X) ----------------------------- +- fix issue751: multiple parametrize with ids bug if it parametrizes class with + two or more test methods. Thanks Sergey Chipiga for reporting and Jan + Bednarik for PR. + - fix issue82: avoid loading conftest files from setup.cfg/pytest.ini/tox.ini files and upwards by default (--confcutdir can still be set to override this). Thanks Bruno Oliveira for the PR. diff --git a/_pytest/mark.py b/_pytest/mark.py index c3dc692f0..50581e0a8 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -291,7 +291,7 @@ class MarkInfo: #: positional argument list, empty if none specified self.args = args #: keyword argument dictionary, empty if nothing specified - self.kwargs = kwargs + self.kwargs = kwargs.copy() self._arglist = [(args, kwargs.copy())] def __repr__(self): diff --git a/testing/python/collect.py b/testing/python/collect.py index dc073b103..5bbff6a64 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -472,6 +472,24 @@ class TestFunction: config.pluginmanager.register(MyPlugin2()) config.hook.pytest_pyfunc_call(pyfuncitem=item) + def test_issue751_multiple_parametrize_with_ids(self, testdir): + modcol = testdir.getmodulecol(""" + import pytest + @pytest.mark.parametrize('x', [0], ids=['c']) + @pytest.mark.parametrize('y', [0, 1], ids=['a', 'b']) + class Test(object): + def test1(self, x, y): + pass + def test2(self, x, y): + pass + """) + colitems = modcol.collect()[0].collect()[0].collect() + assert colitems[0].name == 'test1[a-c]' + assert colitems[1].name == 'test1[b-c]' + assert colitems[2].name == 'test2[a-c]' + assert colitems[3].name == 'test2[b-c]' + + class TestSorting: def test_check_equality(self, testdir): modcol = testdir.getmodulecol("""