Skip to content
Merged
Changes from 2 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
8 changes: 5 additions & 3 deletions Lib/ctypes/test/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A testcase which accesses *values* in a dll.
"""

import imp
import _imp
import importlib.util
import unittest
import sys
Expand Down Expand Up @@ -73,15 +73,17 @@ class struct_frozen(Structure):
self.assertTrue([entry.code[i] for i in range(abs(entry.size))])
# Check the module's package-ness.
with import_helper.frozen_modules():
spec = importlib.util.find_spec(modname)
# Hide the message written by the __hello__ module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop this comment.

with captured_stdout():
spec = importlib.util.find_spec(modname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it wouldn't be useful to just not print anything from the __hello__ module unless it's invoked as a __main__ module? That could possibly allow us to remove a lot of captured_stdout() calls. What is this output actually needed for (other than tradition)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure we didn't think about it when the module was added.

if entry.size < 0:
# It's a package.
self.assertIsNotNone(spec.submodule_search_locations)
else:
self.assertIsNone(spec.submodule_search_locations)

with import_helper.frozen_modules():
expected = imp._frozen_module_names()
expected = _imp._frozen_module_names()
self.maxDiff = None
self.assertEqual(modules, expected, "PyImport_FrozenModules example "
"in Doc/library/ctypes.rst may be out of date")
Expand Down