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

TypeError: 'LazyFixture' object is not subscriptable #58

Open
flazzarini opened this issue Oct 10, 2022 · 0 comments
Open

TypeError: 'LazyFixture' object is not subscriptable #58

flazzarini opened this issue Oct 10, 2022 · 0 comments

Comments

@flazzarini
Copy link

Hi there,

I was trying to do the following code which results in a Exception being thrown. I was wondering if someone has found a way to use the returned object from a lazy_fixture in the parametrize values

import pytest
from pytest_lazyfixture import lazy_fixture

@pytest.fixture
def one():
    return {
        "foo1": "bar",
        "foo2": "baz",
    }

@pytest.mark.parametrize(
    'attr1',
    [
        (lazy_fixture('one')["foo1"], ),
    ]
)
def test_func(attr1):
    assert attr1 == "bar"
============================================================================================================= test session starts =============================================================================================================
platform linux -- Python 3.10.5, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/users/frank/workspace/pseudopiper, configfile: pytest.ini
plugins: xdist-2.5.0, cov-4.0.0, lazy-fixture-0.6.3, clarity-1.0.1, icdiff-0.6, forked-1.4.0
collected 0 items / 1 error

=================================================================================================================== ERRORS ====================================================================================================================
___________________________________________________________________________________________________ ERROR collecting tests/test_foobar2.py ____________________________________________________________________________________________________
tests/test_foobar2.py:14: in <module>
    (lazy_fixture('one')["foo1"], ),
E   TypeError: 'LazyFixture' object is not subscriptable
=========================================================================================================== short test summary info ===========================================================================================================
ERROR tests/test_foobar2.py - TypeError: 'LazyFixture' object is not subscriptable
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================================== 1 error in 0.21s ===============================================================================================================
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

1 participant