Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py.test can't multiple parametrize with ids if it parametrizes class with two or more test methods #751

Closed
pytestbot opened this issue May 23, 2015 · 0 comments
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: sergey chipiga (BitBucket: schipiga, GitHub: schipiga)


Code example

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

stack trace

py.test proba.py --collect-only
============================================================================== test session starts ===============================================================================
platform darwin -- Python 2.7.9 -- py-1.4.26 -- pytest-2.7.0
rootdir: /Users/lira/tmp, inifile: 
collected 0 items / 1 errors 

===================================================================================== ERRORS =====================================================================================
___________________________________________________________________________ ERROR collecting proba.py ____________________________________________________________________________
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/runner.py:149: in __init__
    self.result = func()
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py:437: in _memocollect
    return self._memoizedcall('_collected', lambda: list(self.collect()))
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py:314: in _memoizedcall
    res = function()
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py:437: in <lambda>
    return self._memoizedcall('_collected', lambda: list(self.collect()))
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/python.py:563: in collect
    return super(Instance, self).collect()
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/python.py:355: in collect
    res = self.makeitem(name, obj)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/python.py:367: in makeitem
    collector=self, name=name, obj=obj)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py:521: in __call__
    return self._docall(self.methods, kwargs)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py:528: in _docall
    firstresult=self.firstresult).execute()
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py:393: in execute
    return wrapped_call(method(*args), self.execute)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py:109: in wrapped_call
    wrap_controller.send(call_outcome)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/python.py:245: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/python.py:384: in _genfunctions
    self.ihook.pytest_generate_tests.callextra(methods, metafunc=metafunc)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py:524: in callextra
    return self._docall(self.methods + methods, kwargs)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py:528: in _docall
    firstresult=self.firstresult).execute()
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py:394: in execute
    res = method(*args)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/python.py:154: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/python.py:859: in parametrize
    len(argvalues), len(ids)))
E   ValueError: 2 tests specified with 1 ids

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
JanBednarik added a commit to JanBednarik/pytest that referenced this issue Jul 25, 2015
JanBednarik added a commit to JanBednarik/pytest that referenced this issue Jul 25, 2015
@JanBednarik JanBednarik mentioned this issue Jul 25, 2015
flub added a commit that referenced this issue Jul 25, 2015
Merge branch 'fix-751' of github.com:JanBednarik/pytest into jb-fix-751
@pfctdayelise pfctdayelise added topic: parametrize related to @pytest.mark.parametrize classes labels Jul 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

2 participants