-
Notifications
You must be signed in to change notification settings - Fork 40
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
Support pytest plugins that modify the fixture closure list #176
Comments
thanks for the feedback @HMaker ! I'll have a look By the way note that you can directly unpack a, b and c as for pytest.mark.parametrize: @parametrize_with_cases("a,b,c", cases='.')
async def test_sum_of(a, b, c):
assert sum(a, b) == c |
(Unfortunately I only fixed half of the issue yet: reopening) |
@HMaker can you confirm that this new version 3.2.0 works for you ? thanks ! |
Up @HMaker ? |
Sorry for late answer, I ran the code I sent above and the same error still happens. Steps to reproduce (linux env): mkdir -p /temp/test-pytest
cd /tmp/test-pytest
python3 -m venv --prompt pytest venv
source venv/bin/activate
pip install pytest pytest-asyncio pytest-cases
cat << EOF > test_case.py
import random
import pytest
from pytest_cases import parametrize_with_cases
def sum(a, b):
return a + b
@pytest.fixture
def random_num():
return random.randint(0, 65543)
def case_1(random_num: int):
return 1, random_num, 1 + random_num
def case_2(random_num: int):
return 2, random_num, 2 + random_num
@pytest.mark.asyncio
@parametrize_with_cases('case', cases='.')
async def test_sum_of(case):
a, b, c = case
assert sum(a, b) == c
EOF
pytest test_case.py and this is the error report from pytest
That
|
Lol it seems that pytest-asyncio inserts it at the beginning of the closure instead of putting it at the end (append). Maybe they changed behaviour in the lastest version ? Or I just dreamed it, but I thought I tested it locally... This will make it a little bit more complex to fix. I'll have to have a go again, thanks a LOT for reporting it ! |
pytest-asyncio 0.14.0 was released in Jun 23, 2020 as shown in its pypi page, so I was using that version (actually it's set to "*" in requirements file, i.e. unpinned) when reported that error for the first time. Anyway, thanks for your attention. |
Yes I saw that. Sorry, I don"t know what have happened. Anyway, I'll try to fix this now, and integrate the fix in the test suite if I can so that at least an independent machine checks it :) I was reluctant to add yet another plugin to the test suite but I guess I have not much choice to ensure proper coverage |
Confirmed: I was using |
I made it work. Here are the current limitations, that should hopefully be quite tolerant to most existing plugins:
I'll try to cut a release soon. Thanks again @HMaker for your feedback ! |
@HMaker I managed to finally release version 3.3.0 that contains the fix. Sorry for the delay, I had to migrate from Travis to Github Actions to get my CI/CD pipelines back. Could you let me know if this is working for you ? Just in case the tested configuration is slightly different from the one you're using. |
I tried to parametrize a test function marked by pytest-asyncio
but
pytest_cases
raisesNotImplementedError: When fixture unions are present, inserting a fixture in the closure is non-trivial. Please report this so that we can find a suitable solution for your need.
That works with pytest-lazy-fixture
Thanks in advance.
The text was updated successfully, but these errors were encountered: