From a9e0d2de9461385c78cc7503abae5bf1ea2348ef Mon Sep 17 00:00:00 2001 From: Juan Altmayer Pizzorno Date: Wed, 28 Aug 2024 20:36:55 -0400 Subject: [PATCH] - fixed test failing with Python < 3.11; --- tests/test_codeinfo.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/test_codeinfo.py b/tests/test_codeinfo.py index 44a2e17..f68aed3 100644 --- a/tests/test_codeinfo.py +++ b/tests/test_codeinfo.py @@ -4,6 +4,7 @@ import typing as T import pytest import coverup.codeinfo as codeinfo +import sys codeinfo._debug = print # enables debugging @@ -12,7 +13,6 @@ @pytest.fixture def importlib_cleanup(): import importlib - import sys previously_loaded = {m for m in sys.modules} @@ -1104,17 +1104,28 @@ def foo(a, b): ) -def test_get_info_frozen_or_builtin_module(import_fixture): +@pytest.mark.skipif(sys.version_info[0:2] < (3,11), reason="not a frozen module then") +def test_get_info_frozen_module(import_fixture): tmp_path = import_fixture code = tmp_path / "foo.py" code.write_text(textwrap.dedent("""\ import os - import sys """ )) tree = codeinfo.parse_file(code) assert codeinfo.get_info(tree, 'os.path.join') == None + +def test_get_info_builtin_module(import_fixture): + tmp_path = import_fixture + + code = tmp_path / "foo.py" + code.write_text(textwrap.dedent("""\ + import sys + """ + )) + + tree = codeinfo.parse_file(code) assert codeinfo.get_info(tree, 'sys.path') == None