use setup-show and extend reproducer with fixture/fixture+autouse checks

This commit is contained in:
Ronny Pfannschmidt 2021-03-07 15:53:47 +01:00
parent 2385d6f9cb
commit 858a785dc6
2 changed files with 19 additions and 1 deletions

View File

@ -35,6 +35,24 @@ class TestSomething(MyPytestBase):
assert os.environ["X"] == "1"
class TestSomethingWithFixture(MyPytestBase):
@pytest.fixture
def setup_method(self):
self.set_environ("X", "1")
def test_something(self):
assert os.environ["X"] == "1"
class TestSomethingWithFixtureAutouse(MyPytestBase):
@pytest.fixture(autouse=True)
def setup_method(self):
self.set_environ("X", "1")
def test_something(self):
assert os.environ["X"] == "1"
# This arrangement works: _monkeypatch runs before setUp
class MyUnittestBase(
EnvironmentAwareMixin,

View File

@ -3,5 +3,5 @@ from _pytest.pytester import Pytester
def test_order(pytester: Pytester) -> None:
pytester.copy_example("order_issue.py")
rep = pytester.runpytest("order_issue.py")
rep = pytester.runpytest("order_issue.py", "--setup-show")
rep.assert_outcomes(passed=2)