Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-106016: Add Lib/test/test_module/ directory #108293

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 18 additions & 18 deletions Lib/test/test_module.py → Lib/test/test_module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,55 +126,55 @@ def test_weakref(self):
self.assertIs(wr(), None)

def test_module_getattr(self):
import test.good_getattr as gga
from test.good_getattr import test
import test.test_module.good_getattr as gga
from test.test_module.good_getattr import test
self.assertEqual(test, "There is test")
self.assertEqual(gga.x, 1)
self.assertEqual(gga.y, 2)
with self.assertRaisesRegex(AttributeError,
"Deprecated, use whatever instead"):
gga.yolo
self.assertEqual(gga.whatever, "There is whatever")
del sys.modules['test.good_getattr']
del sys.modules['test.test_module.good_getattr']

def test_module_getattr_errors(self):
import test.bad_getattr as bga
from test import bad_getattr2
import test.test_module.bad_getattr as bga
from test.test_module import bad_getattr2
self.assertEqual(bga.x, 1)
self.assertEqual(bad_getattr2.x, 1)
with self.assertRaises(TypeError):
bga.nope
with self.assertRaises(TypeError):
bad_getattr2.nope
del sys.modules['test.bad_getattr']
if 'test.bad_getattr2' in sys.modules:
del sys.modules['test.bad_getattr2']
del sys.modules['test.test_module.bad_getattr']
if 'test.test_module.bad_getattr2' in sys.modules:
del sys.modules['test.test_module.bad_getattr2']

def test_module_dir(self):
import test.good_getattr as gga
import test.test_module.good_getattr as gga
self.assertEqual(dir(gga), ['a', 'b', 'c'])
del sys.modules['test.good_getattr']
del sys.modules['test.test_module.good_getattr']

def test_module_dir_errors(self):
import test.bad_getattr as bga
from test import bad_getattr2
import test.test_module.bad_getattr as bga
from test.test_module import bad_getattr2
with self.assertRaises(TypeError):
dir(bga)
with self.assertRaises(TypeError):
dir(bad_getattr2)
del sys.modules['test.bad_getattr']
if 'test.bad_getattr2' in sys.modules:
del sys.modules['test.bad_getattr2']
del sys.modules['test.test_module.bad_getattr']
if 'test.test_module.bad_getattr2' in sys.modules:
del sys.modules['test.test_module.bad_getattr2']

def test_module_getattr_tricky(self):
from test import bad_getattr3
from test.test_module import bad_getattr3
# these lookups should not crash
with self.assertRaises(AttributeError):
bad_getattr3.one
with self.assertRaises(AttributeError):
bad_getattr3.delgetattr
if 'test.bad_getattr3' in sys.modules:
del sys.modules['test.bad_getattr3']
if 'test.test_module.bad_getattr3' in sys.modules:
del sys.modules['test.test_module.bad_getattr3']

def test_module_repr_minimal(self):
# reprs when modules have no __file__, __name__, or __loader__
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,7 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_importlib/resources/zipdata02 \
test/test_importlib/source \
test/test_json \
test/test_module \
test/test_peg_generator \
test/test_sqlite3 \
test/test_tkinter \
Expand Down