Added ut to make sure PYTEST_VERSION is added and removed from env properly

This commit is contained in:
dheerajck 2024-03-23 21:27:56 +05:30
parent c3e8ec8989
commit 6bb894a521
1 changed files with 17 additions and 0 deletions

View File

@ -1094,3 +1094,20 @@ def test_outcome_exception_bad_msg() -> None:
with pytest.raises(TypeError) as excinfo:
OutcomeException(func) # type: ignore
assert str(excinfo.value) == expected
def test_pytest_version(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
pytester.makepyfile(
"""
import pytest
import os
def test():
assert os.environ.get("PYTEST_VERSION") == pytest.__version__
"""
)
result = pytester.runpytest_inprocess()
# assert result.ret == 0
assert result.ret == ExitCode.OK
assert "PYTEST_VERSION" not in os.environ