假设 pytest 会话装置返回一个字典,然后在测试中操作该字典。这会影响后续测试吗?
是的。这很容易验证。这些测试中的一项将会失败:
import pytest @pytest.fixture(scope="session") def d(): return {} def test_one(d): assert not d d["k"] = "v" def test_two(d): assert not d d["k"] = "v"