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

cannot use a lazy fixture if it directly returns a list #25

Open
drake-mer opened this issue Jun 10, 2018 · 3 comments
Open

cannot use a lazy fixture if it directly returns a list #25

drake-mer opened this issue Jun 10, 2018 · 3 comments

Comments

@drake-mer
Copy link

# -*- coding: utf-8 -*-

import string
import pytest


@pytest.fixture
def list_of_tuple_for_testing():
    yield [(ord(x), x) for x in string.ascii_uppercase]


@pytest.mark.parametrize(
    'chr_code, chr_object',
    pytest.lazy_fixture('list_of_tuple_for_testing')
)
def test_all_files(chr_code, chr_object):
    assert chr(chr_code) == chr_object
================================================================================ ERRORS ================================================================================
________________________________________________________________ ERROR collecting test_lazy_fixture.py _________________________________________________________________
/usr/lib/python3.6/site-packages/pluggy/__init__.py:617: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
/usr/lib/python3.6/site-packages/pluggy/__init__.py:222: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.6/site-packages/pluggy/__init__.py:216: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
/usr/lib/python3.6/site-packages/_pytest/python.py:240: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
/usr/lib/python3.6/site-packages/_pytest/python.py:432: in _genfunctions
    self.ihook.pytest_generate_tests(metafunc=metafunc)
/usr/lib/python3.6/site-packages/pluggy/__init__.py:617: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
/usr/lib/python3.6/site-packages/pluggy/__init__.py:222: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.6/site-packages/pluggy/__init__.py:216: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
/usr/lib/python3.6/site-packages/_pytest/python.py:161: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
/usr/lib/python3.6/site-packages/_pytest/python.py:872: in parametrize
    argnames, argvalues, self.function, self.config
/usr/lib/python3.6/site-packages/_pytest/mark/structures.py:106: in _for_parametrize
    for x in argvalues
E   TypeError: 'LazyFixture' object is not iterable
@tnixon
Copy link

tnixon commented Jul 2, 2019

I've just run into a situation where this would be very useful to have!
(Code generates list of objects, I'd like to run a battery of tests on each - by passing the list to a parameterization)

@davidstrouk
Copy link

Any news regarding this? I know this thread is old, but I have the exact same issue.

@Ben621
Copy link

Ben621 commented Dec 13, 2021

Hey i have the same problem
Someone find a workaround @davidstrouk @tnixon ?

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

4 participants