Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revise the test for clarity and traceability.
  • Loading branch information
jaraco committed Apr 12, 2026
commit 6e2183f425ce89a743db51288dc6097ac8a8e115
12 changes: 8 additions & 4 deletions importlib_resources/tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,17 @@ class ResourceFromNamespaceZipTests(
MODULE = 'namespacedata01'


class ResourceFromMainModuleWithNoneSpecTests(unittest.TestCase):
# `__main__.__spec__` can be `None` depending on how it is populated.
# https://docs.python.org/3/reference/import.html#main-spec
class MainModuleTests(unittest.TestCase):
def test_main_module_with_none_spec(self):
"""
__main__ module with no spec should raise TypeError (for clarity).

See python/cpython#138531 for details.
"""
# construct a __main__ module with no __spec__.
mainmodule = types.ModuleType("__main__")

self.assertIsNone(mainmodule.__spec__)
assert mainmodule.__spec__ is None

with self.assertRaises(
TypeError,
Expand Down