From 4c3bf08947a9fa37e2463628d20c8316dc6dd71b Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sat, 27 Aug 2022 16:51:33 -0400 Subject: Fix namespace package detection for frozen stdlib modules on PyPy (#1757) --- tests/unittest_manager.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unittest_manager.py b/tests/unittest_manager.py index 5bce2904..fd5787d4 100644 --- a/tests/unittest_manager.py +++ b/tests/unittest_manager.py @@ -10,9 +10,11 @@ import unittest from collections.abc import Iterator from contextlib import contextmanager +import pytest + import astroid from astroid import manager, test_utils -from astroid.const import IS_JYTHON +from astroid.const import IS_JYTHON, IS_PYPY from astroid.exceptions import AstroidBuildingError, AstroidImportError from astroid.interpreter._import import util from astroid.modutils import is_standard_module @@ -128,6 +130,7 @@ class AstroidManagerTest( def test_module_is_not_namespace(self) -> None: self.assertFalse(util.is_namespace("tests.testdata.python3.data.all")) self.assertFalse(util.is_namespace("__main__")) + self.assertFalse(util.is_namespace("importlib._bootstrap")) def test_module_unexpectedly_missing_spec(self) -> None: astroid_module = sys.modules["astroid"] @@ -155,6 +158,10 @@ class AstroidManagerTest( for _ in range(2): sys.path.pop(0) + @pytest.mark.skipif( + IS_PYPY, + reason="PyPy provides no way to tell apart frozen stdlib from old-style namespace packages", + ) def test_namespace_package_pth_support(self) -> None: pth = "foogle_fax-0.12.5-py2.7-nspkg.pth" site.addpackage(resources.RESOURCE_PATH, pth, []) @@ -169,6 +176,10 @@ class AstroidManagerTest( finally: sys.modules.pop("foogle") + @pytest.mark.skipif( + IS_PYPY, + reason="PyPy provides no way to tell apart frozen stdlib from old-style namespace packages", + ) def test_nested_namespace_import(self) -> None: pth = "foogle_fax-0.12.5-py2.7-nspkg.pth" site.addpackage(resources.RESOURCE_PATH, pth, []) -- cgit v1.2.1