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

Standard PyTest parametrize decorator broken #62

Closed
rafspiny opened this issue Oct 22, 2019 · 2 comments
Closed

Standard PyTest parametrize decorator broken #62

rafspiny opened this issue Oct 22, 2019 · 2 comments

Comments

@rafspiny
Copy link

When using a standard parametrize decorator while pytest_cases is installed, seems to cause these tests to become broken.
If I uninstall pytest_cases I am able to collect the test and run it, successufully.

I am attaching a very simple example to reproduce it.

I am using the following versions:

$ pip freeze | grep -i pytest

pytest==4.6.4
pytest-cases==1.11.3
pytest-cov==2.5.1
pytest-forked==1.0.2
pytest-freezegun==0.3.0.post1
pytest-mock==1.6.3
pytest-xdist==1.21.0

from __future__ import unicode_literals
import pytest
from typing import Text

@pytest.fixture
def my_cool_fixture():
    return Text('hello world')

@pytest.mark.parametrize('object_id', ['a1', 'b2', 'b3'])
def test_my_cool_feature_with_fixture(my_cool_fixture, object_id):
    print(my_cool_fixture)
    print(object_id)
    pass

Leads to the following output:

../../../.env/local/lib/python2.7/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
../../../.env/local/lib/python2.7/site-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../../.env/local/lib/python2.7/site-packages/pluggy/manager.py:86: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
../../../.env/local/lib/python2.7/site-packages/_pytest/python.py:234: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
../../../.env/local/lib/python2.7/site-packages/_pytest/python.py:394: in _genfunctions
    definition = FunctionDefinition(name=name, parent=self, callobj=funcobj)
../../../.env/local/lib/python2.7/site-packages/_pytest/python.py:1429: in __init__
    self, self.obj, self.cls, funcargs=True
../../../.env/local/lib/python2.7/site-packages/_pytest/fixtures.py:1163: in getfixtureinfo
    initialnames, node, ignore_args=self._get_direct_parametrize_args(node)
../../../.env/local/lib/python2.7/site-packages/pytest_cases/plugin.py:510: in getfixtureclosure
    sorted_fixturenames = sort_according_to_ref_list(fixturenames, param_names)
../../../.env/local/lib/python2.7/site-packages/pytest_cases/plugin.py:978: in sort_according_to_ref_list
    cur_indices.append(fixturenames.index(pname))
E   ValueError: tuple.index(x): x not in tuple
@smarie
Copy link
Owner

smarie commented Oct 23, 2019

Thanks for reporting this ! it is a python-2 only issue apparently, due to the fact that at some point I do isinstance(argnames, str) and this returns false when argnames is a python 2 string.

I'll fix this in a minute.

@smarie smarie closed this as completed in 9742da0 Oct 23, 2019
@smarie
Copy link
Owner

smarie commented Oct 23, 2019

1.11.4 release should do the trick, feel free to reopen if that does not. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants