-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
topic: parametrizerelated to @pytest.mark.parametrizerelated to @pytest.mark.parametrizetype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
Originally reported by: Nikolaus Rath (BitBucket: nikratio, GitHub: nikratio)
Consider the attached test case. Both fixtures are defined with module scope, so they should be called just once for each parameter value.
However, sometimes the "bar" fixture is called twice for the same parameter value. Example:
#!
$ py.test-3 test_bug.py -s
============================= test session starts =============================
platform linux -- Python 3.4.2 -- py-1.4.25 -- pytest-2.6.3
plugins: capturelog, ordering
collected 4 items
test_bug.py preparing bar-1
preparing bar-1/foo-1
.preparing bar-2
preparing bar-2/foo-1
.preparing bar-2/foo-2
.preparing bar-1
preparing bar-1/foo-2
.
========================== 4 passed in 0.01 seconds ===========================
$ py.test-3 test_bug.py -s
============================= test session starts =============================
platform linux -- Python 3.4.2 -- py-1.4.25 -- pytest-2.6.3
plugins: capturelog, ordering
collected 4 items
test_bug.py preparing bar-1
preparing bar-1/foo-1
.preparing bar-1/foo-2
.preparing bar-2
preparing bar-2/foo-2
.preparing bar-2/foo-1
.
========================== 4 passed in 0.01 seconds ===========================
I think the number of calls to a fixture should be determinstic and reproducible.
Moreover, I think the second run (where "preparing bar-1" is printed only once) is correct.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
topic: parametrizerelated to @pytest.mark.parametrizerelated to @pytest.mark.parametrizetype: bugproblem that needs to be addressedproblem that needs to be addressed