-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
I have some test cases in which I need more than one lazy fixture (one for each parameter).
The problem is that the pytest discovery is creating different test names in every run, which creates a problem in the interaction with tools like VScode. I don't know if it's a pytest issue or pytest-lazy-fixtures one.
Here's an example of a test that uses two lazy fixtures:
import pytest
from pytest import fixture
from pytest_lazyfixture import lazy_fixture
@fixture(params=[1, 2, 3])
def all_numbers(request):
return request.param
@fixture(params=["a", "b", "c"])
def all_letters(request):
return request.param
@pytest.mark.parametrize(
"number,letter",
[lazy_fixture(["all_numbers", "all_letters"])]
)
def test_multiple_lazy(number, letter):
print(number, letter)
This is one pytest collect run:
pytest --collect-only
=================================================================== test session starts ====================================================================
platform darwin -- Python 3.11.0, pytest-7.2.0, pluggy-0.13.1
rootdir: /Users/fraimondo/dev/scratch/pytest_order
plugins: typeguard-2.13.3, lazy-fixture-0.6.3
collected 9 items
<Module test_multiple_lazy.py>
<Function test_multiple_lazy[all_numbers-all_letters-a-1]>
<Function test_multiple_lazy[all_numbers-all_letters-a-2]>
<Function test_multiple_lazy[all_numbers-all_letters-a-3]>
<Function test_multiple_lazy[all_numbers-all_letters-b-1]>
<Function test_multiple_lazy[all_numbers-all_letters-b-2]>
<Function test_multiple_lazy[all_numbers-all_letters-b-3]>
<Function test_multiple_lazy[all_numbers-all_letters-c-1]>
<Function test_multiple_lazy[all_numbers-all_letters-c-2]>
<Function test_multiple_lazy[all_numbers-all_letters-c-3]>
This is another one:
pytest --collect-only
=================================================================== test session starts ====================================================================
platform darwin -- Python 3.11.0, pytest-7.2.0, pluggy-0.13.1
rootdir: /Users/fraimondo/dev/scratch/pytest_order
plugins: typeguard-2.13.3, lazy-fixture-0.6.3
collected 9 items
<Module test_multiple_lazy.py>
<Function test_multiple_lazy[all_numbers-all_letters-1-a]>
<Function test_multiple_lazy[all_numbers-all_letters-1-b]>
<Function test_multiple_lazy[all_numbers-all_letters-1-c]>
<Function test_multiple_lazy[all_numbers-all_letters-2-a]>
<Function test_multiple_lazy[all_numbers-all_letters-2-b]>
<Function test_multiple_lazy[all_numbers-all_letters-2-c]>
<Function test_multiple_lazy[all_numbers-all_letters-3-a]>
<Function test_multiple_lazy[all_numbers-all_letters-3-b]>
<Function test_multiple_lazy[all_numbers-all_letters-3-c]>
Metadata
Metadata
Assignees
Labels
No labels