aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_capi.py')
-rw-r--r--Lib/test/test_capi.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 67175cd044a..5f5c0d038d9 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -569,12 +569,23 @@ class CAPITest(unittest.TestCase):
self.assertEqual(len(modules), total)
def test_fatal_error(self):
+ # By default, stdlib extension modules are ignored,
+ # but not test modules.
expected = ('_testcapi',)
- not_expected = ('sys', 'builtins', '_imp', '_thread', '_weakref',
- '_io', 'marshal', '_signal', '_abc')
- code = 'import _testcapi; _testcapi.fatal_error(b"MESSAGE")'
+ not_expected = ('sys',)
+ code = 'import _testcapi, sys; _testcapi.fatal_error(b"MESSAGE")'
self.check_fatal_error(code, expected, not_expected)
+ # Mark _testcapi as stdlib module, but not sys
+ expected = ('sys',)
+ not_expected = ('_testcapi',)
+ code = textwrap.dedent('''
+ import _testcapi, sys
+ sys.module_names = frozenset({"_testcapi"})
+ _testcapi.fatal_error(b"MESSAGE")
+ ''')
+ self.check_fatal_error(code, expected)
+
class TestPendingCalls(unittest.TestCase):