use setup-show and extend reproducer with fixture/fixture+autouse checks
This commit is contained in:
parent
2385d6f9cb
commit
858a785dc6
|
@ -35,6 +35,24 @@ class TestSomething(MyPytestBase):
|
||||||
assert os.environ["X"] == "1"
|
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
|
# This arrangement works: _monkeypatch runs before setUp
|
||||||
class MyUnittestBase(
|
class MyUnittestBase(
|
||||||
EnvironmentAwareMixin,
|
EnvironmentAwareMixin,
|
||||||
|
|
|
@ -3,5 +3,5 @@ from _pytest.pytester import Pytester
|
||||||
|
|
||||||
def test_order(pytester: Pytester) -> None:
|
def test_order(pytester: Pytester) -> None:
|
||||||
pytester.copy_example("order_issue.py")
|
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)
|
rep.assert_outcomes(passed=2)
|
||||||
|
|
Loading…
Reference in New Issue