diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2022-10-15 12:33:23 -0400 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2022-10-15 14:14:20 -0400 |
| commit | 05b8e8baec9f81463f6fba7df286ddcadab614aa (patch) | |
| tree | 907323e661993918e805fa99f6816c481fc4ce2c /tests | |
| parent | 2bdcd08522f5088cc565995af4e083c38e60ae6c (diff) | |
| download | astroid-git-05b8e8baec9f81463f6fba7df286ddcadab614aa.tar.gz | |
Prevent a crash when a module's ``__path__`` is missing
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unittest_manager.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/unittest_manager.py b/tests/unittest_manager.py index 1c8a3fdc..2266e32a 100644 --- a/tests/unittest_manager.py +++ b/tests/unittest_manager.py @@ -9,6 +9,7 @@ import time import unittest from collections.abc import Iterator from contextlib import contextmanager +from unittest import mock import pytest @@ -144,6 +145,14 @@ class AstroidManagerTest( finally: astroid_module.__spec__ = original_spec + @mock.patch( + "astroid.interpreter._import.util._find_spec_from_path", + side_effect=AttributeError, + ) + def test_module_unexpectedly_missing_path(self, mocked) -> None: + """https://github.com/PyCQA/pylint/issues/7592""" + self.assertFalse(util.is_namespace("astroid")) + def test_module_unexpectedly_spec_is_none(self) -> None: astroid_module = sys.modules["astroid"] original_spec = astroid_module.__spec__ |
