File tree 1 file changed +34
-0
lines changed 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -2547,6 +2547,40 @@ def test_foo(fix):
2547
2547
'*test_foo*alpha*' ,
2548
2548
'*test_foo*beta*' ])
2549
2549
2550
+ @pytest .mark .issue920
2551
+ @pytest .mark .xfail (reason = "Fixture reordering not deterministic with hash randomisation" )
2552
+ def test_deterministic_fixture_collection (self , testdir , monkeypatch ):
2553
+ testdir .makepyfile ("""
2554
+ import pytest
2555
+
2556
+ @pytest.fixture(scope="module",
2557
+ params=["A",
2558
+ "B",
2559
+ "C"])
2560
+ def A(request):
2561
+ return request.param
2562
+
2563
+ @pytest.fixture(scope="module",
2564
+ params=["DDDDDDDDD", "EEEEEEEEEEEE", "FFFFFFFFFFF", "banansda"])
2565
+ def B(request, A):
2566
+ return request.param
2567
+
2568
+ def test_foo(B):
2569
+ # Something funky is going on here.
2570
+ # Despite specified seeds, on what is collected,
2571
+ # sometimes we get unexpected passes. hashing B seems
2572
+ # to help?
2573
+ assert hash(B) or True
2574
+ """ )
2575
+ monkeypatch .setenv ("PYTHONHASHSEED" , "1" )
2576
+ out1 = testdir .runpytest_subprocess ("-v" )
2577
+ monkeypatch .setenv ("PYTHONHASHSEED" , "2" )
2578
+ out2 = testdir .runpytest_subprocess ("-v" )
2579
+ out1 = [line for line in out1 .outlines if line .startswith ("test_deterministic_fixture_collection.py::test_foo" )]
2580
+ out2 = [line for line in out2 .outlines if line .startswith ("test_deterministic_fixture_collection.py::test_foo" )]
2581
+ assert len (out1 ) == 12
2582
+ assert out1 == out2
2583
+
2550
2584
2551
2585
class TestRequestScopeAccess (object ):
2552
2586
pytestmark = pytest .mark .parametrize (("scope" , "ok" , "error" ), [
You can’t perform that action at this time.
0 commit comments