sample_python_pytest.py 222 B

12345678910111213141516171819202122232425
  1. import pytest
  2. x = 1
  3. @pytest.fixture()
  4. def f1():
  5. global x
  6. x = 2
  7. yield 15
  8. x = 3
  9. def test_1():
  10. assert x == 1
  11. def test_2(f1):
  12. assert x == 2
  13. assert f1 == 15
  14. def test_3():
  15. assert x == 3