Open steadyfirmness opened 5 days ago
I have some fixtures in the same test file, and I need to reload one of them as following:
@pytest.fixture() def f1(): return 1 @pytest.fixture(name="f1") def f0(): return 0
When i call “f1” its return 0 because its actually executed “f0” as following:
class TestLib: def test_1(self, f1): assert f1 == 0
But this is fail for test
________________________________ TestLib.test_1 ________________________________ self = <lib.test.test_lib.TestLib object at 0x104b3df40>, f1 = 1 def test_1(self, f1): > assert f1 == 0 E assert 1 == 0 lib/test/test_lib.py:21: AssertionError =========================== short test summary info ============================ FAILED lib/test/test_lib.py::TestLib::test_1 - assert 1 == 0
os:mac 15.0.1 python:3.12.4 pytest:8.3.2
When I change name ‘f0’ -> 'f2', as following, it works well:
@pytest.fixture() def f1(): return 1 @pytest.fixture(name="f1") def f2(): return 2
So I summarized that the overloading of fixtures in the same file is not in the order of bytecode compilation, but in the lexicographic order of functions, resulting in the phenomenon where f0 cannot reload f1 while f2 can reload f1.
I'm not sure if this is a feature or a bug
We should error on such conflicts
description
I have some fixtures in the same test file, and I need to reload one of them as following:
what i want
When i call “f1” its return 0 because its actually executed “f0” as following:
pytest result
But this is fail for test
env
os:mac 15.0.1 python:3.12.4 pytest:8.3.2
more detail
When I change name ‘f0’ -> 'f2', as following, it works well:
So I summarized that the overloading of fixtures in the same file is not in the order of bytecode compilation, but in the lexicographic order of functions, resulting in the phenomenon where f0 cannot reload f1 while f2 can reload f1.
I'm not sure if this is a feature or a bug