From efe4dcff37c7bc55df8e043c0efb0a9b38ccdfe4 Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Fri, 12 Apr 2024 17:53:47 -0400 Subject: [PATCH] contextual patch() --- tests/test_init.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_init.py b/tests/test_init.py index cc938fa..27074ef 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -11,14 +11,13 @@ import pytest from ntclient import version_check -@patch("sys.version_info", (3, 4, 0)) def test_archaic_python_version_raises_runtime_error() -> None: """Test that the correct error is raised when the Python version is too low.""" - with pytest.raises(RuntimeError) as exc_info: - version_check() - assert "ERROR: nutra requires Python 3.4.3 or later to run" in str(exc_info.value) - assert "HINT: You're running Python 3.4.0" in str(exc_info.value) + with patch("sys.version_info", (3, 4, 0)): + with pytest.raises(RuntimeError) as exc_info: + version_check() + assert exc_info.type == RuntimeError assert exc_info.value.args == ( "ERROR: nutra requires Python 3.4.3 or later to run", -- 2.52.0