Skip to content

Commit

Permalink
add substr test
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Jan 22, 2024
1 parent 9f0955d commit 24ccd8a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,15 @@ def test_shadowing_stdlib_sys_edge_cases(self):
import types
collections.__spec__ = types.SimpleNamespace()
collections.__spec__.origin = os.path.join(os.getcwd(), 'collections.py')
class substr(str):
__hash__ = None
collections.__name__ = substr('collections')
try:
collections.does_not_exist
except TypeError as e:
print(str(e))
import sys
sys.stdlib_module_names = None
try:
Expand All @@ -840,6 +849,7 @@ def test_shadowing_stdlib_sys_edge_cases(self):
popen = script_helper.spawn_python('-c', program)
stdout, stderr = popen.communicate()
self.assertEqual(stdout.splitlines(), [
b"unhashable type: 'substr'",
b"module 'collections' has no attribute 'does_not_exist'",
b"module 'collections' has no attribute 'does_not_exist'",
])
Expand Down

0 comments on commit 24ccd8a

Please sign in to comment.