Merge fix for #751

Merge branch 'fix-751' of github.com:JanBednarik/pytest into jb-fix-751
This commit is contained in:
Floris Bruynooghe 2015-07-25 19:03:44 +02:00
commit 251fc68ef9
3 changed files with 23 additions and 1 deletions

View File

@ -1,6 +1,10 @@
2.8.0.dev (compared to 2.7.X) 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 - 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). files and upwards by default (--confcutdir can still be set to override this).
Thanks Bruno Oliveira for the PR. Thanks Bruno Oliveira for the PR.

View File

@ -291,7 +291,7 @@ class MarkInfo:
#: positional argument list, empty if none specified #: positional argument list, empty if none specified
self.args = args self.args = args
#: keyword argument dictionary, empty if nothing specified #: keyword argument dictionary, empty if nothing specified
self.kwargs = kwargs self.kwargs = kwargs.copy()
self._arglist = [(args, kwargs.copy())] self._arglist = [(args, kwargs.copy())]
def __repr__(self): def __repr__(self):

View File

@ -472,6 +472,24 @@ class TestFunction:
config.pluginmanager.register(MyPlugin2()) config.pluginmanager.register(MyPlugin2())
config.hook.pytest_pyfunc_call(pyfuncitem=item) 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: class TestSorting:
def test_check_equality(self, testdir): def test_check_equality(self, testdir):
modcol = testdir.getmodulecol(""" modcol = testdir.getmodulecol("""