(pytester: Pytester, monkeypatch: MonkeyPatch)
| 908 | |
| 909 | |
| 910 | def test_current_test_env_var(pytester: Pytester, monkeypatch: MonkeyPatch) -> None: |
| 911 | pytest_current_test_vars: List[Tuple[str, str]] = [] |
| 912 | monkeypatch.setattr( |
| 913 | sys, "pytest_current_test_vars", pytest_current_test_vars, raising=False |
| 914 | ) |
| 915 | pytester.makepyfile( |
| 916 | """ |
| 917 | import pytest |
| 918 | import sys |
| 919 | import os |
| 920 | |
| 921 | @pytest.fixture |
| 922 | def fix(): |
| 923 | sys.pytest_current_test_vars.append(('setup', os.environ['PYTEST_CURRENT_TEST'])) |
| 924 | yield |
| 925 | sys.pytest_current_test_vars.append(('teardown', os.environ['PYTEST_CURRENT_TEST'])) |
| 926 | |
| 927 | def test(fix): |
| 928 | sys.pytest_current_test_vars.append(('call', os.environ['PYTEST_CURRENT_TEST'])) |
| 929 | """ |
| 930 | ) |
| 931 | result = pytester.runpytest_inprocess() |
| 932 | assert result.ret == 0 |
| 933 | test_id = "test_current_test_env_var.py::test" |
| 934 | assert pytest_current_test_vars == [ |
| 935 | ("setup", test_id + " (setup)"), |
| 936 | ("call", test_id + " (call)"), |
| 937 | ("teardown", test_id + " (teardown)"), |
| 938 | ] |
| 939 | assert "PYTEST_CURRENT_TEST" not in os.environ |
| 940 | |
| 941 | |
| 942 | class TestReportContents: |
nothing calls this directly
no test coverage detected