Apply suggestions from code review

Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
This commit is contained in:
dj 2024-04-07 18:24:35 +05:30 committed by GitHub
parent dff74a9bf4
commit 237ea1ac23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View File

@ -1 +1 @@
Added an environment variable which helps to check if a code is running from within a pytest run Added :envvar:`PYTEST_VERSION` environment variable which is defined at the start of the pytest session and undefined afterwards. It contains the value of ``pytest.__version__``, and among other things can be used to easily check if code is running from within a pytest run.

View File

@ -1096,7 +1096,7 @@ def test_outcome_exception_bad_msg() -> None:
assert str(excinfo.value) == expected assert str(excinfo.value) == expected
def test_pytest_version(pytester: Pytester, monkeypatch: MonkeyPatch) -> None: def test_pytest_version_env_var(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
pytester.makepyfile( pytester.makepyfile(
""" """
import pytest import pytest
@ -1108,6 +1108,5 @@ def test_pytest_version(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
""" """
) )
result = pytester.runpytest_inprocess() result = pytester.runpytest_inprocess()
# assert result.ret == 0
assert result.ret == ExitCode.OK assert result.ret == ExitCode.OK
assert "PYTEST_VERSION" not in os.environ assert "PYTEST_VERSION" not in os.environ