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-103899: Provide a hint when accidentally calling a module #103900

Merged
merged 6 commits into from
May 4, 2023
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
Add more tests
  • Loading branch information
brandtbucher committed Apr 26, 2023
commit 833144d2997778786da70504bac9df3b411cfd50
14 changes: 13 additions & 1 deletion Lib/test/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,24 @@ def test_module_not_callable_no_suggestion_0(self):
msg = r"^'module' object is not callable$"
self.assertRaisesRegex(TypeError, msg, types.ModuleType("mod"))

def test_module_not_callable_not_suggestion_1(self):
def test_module_not_callable_no_suggestion_1(self):
msg = r"^'module' object is not callable$"
mod = types.ModuleType("mod")
mod.mod = 42
self.assertRaisesRegex(TypeError, msg, mod)

def test_module_not_callable_no_suggestion_2(self):
msg = r"^'module' object is not callable$"
mod = types.ModuleType("mod")
del mod.__name__
self.assertRaisesRegex(TypeError, msg, mod)

def test_module_not_callable_no_suggestion_3(self):
msg = r"^'module' object is not callable$"
mod = types.ModuleType("mod")
mod.__name__ = 42
self.assertRaisesRegex(TypeError, msg, mod)

def test_module_not_callable_suggestion(self):
msg = r"^'module' object is not callable\. Did you mean: 'mod\.mod\(\.\.\.\)'\?$"
mod = types.ModuleType("mod")
Expand Down