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

Stacktraces fail when one session scoped fixture depending on another session scoped fixture crashes #31

Open
chrisoaks opened this issue Feb 10, 2023 · 0 comments · May be fixed by #68

Comments

@chrisoaks
Copy link

import pytest


@pytest.fixture(scope="session")
def first():
    return "first"


@pytest.fixture(scope="session")
async def second(first):
    assert False


@pytest.mark.asyncio_cooperative
async def test_hello(second):
    print("hello")

If these fixtures were not session scoped we would see:

    @pytest.fixture
    async def second(first):
>       assert False
E       assert False

However when these fixtures are declared to have a session scope we see:

in call_fixture_func
    fixture_result = fixturefunc(**kwargs)
E   TypeError: CachedFunction.__call__() got an unexpected keyword argument 'first'

Especially when working with complex and nested fixtures, it's valuable to be able to see the line that causes an error, rather than only an unrelated line belonging to pytest.

kylegentle added a commit to kylegentle/pytest-asyncio-cooperative that referenced this issue Jul 29, 2024
Fixes willemt#31. This is mostly a cherry-pick of @kstech-roadie's willemt@5d0c7ab, with one additional callsite fixed and a comment added about kwargs support for caching.
@kylegentle kylegentle linked a pull request Jul 29, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant