summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2009-03-31 19:33:15 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2009-03-31 19:33:15 (GMT)
commitbdeacba51bfebf18164fa82cfefd59dcd5ba2498 (patch)
tree9c5393b6069247a949af4ff129337bacbd73a91c /Lib/test/test_support.py
parentdf90b024159632f38b269063ae4b0cad9be40698 (diff)
downloadcpython-bdeacba51bfebf18164fa82cfefd59dcd5ba2498.zip
cpython-bdeacba51bfebf18164fa82cfefd59dcd5ba2498.tar.gz
cpython-bdeacba51bfebf18164fa82cfefd59dcd5ba2498.tar.bz2
Improve test_support.import_module docstring, remove
deprecated flag from get_attribute since it isn't likely to do anything useful.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 3df1b27..0693850 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -43,8 +43,11 @@ class ResourceDenied(unittest.SkipTest):
"""
def import_module(name, deprecated=False):
- """Import the module to be tested, raising SkipTest if it is not
- available."""
+ """Import and return the module to be tested, raising SkipTest if
+ it is not available.
+
+ If deprecated is True, any module or package deprecation messages
+ will be suppressed."""
with warnings.catch_warnings():
if deprecated:
warnings.filterwarnings("ignore", ".+ (module|package)",
@@ -56,20 +59,15 @@ def import_module(name, deprecated=False):
else:
return module
-def get_attribute(module, name, deprecated=False):
- """Get an attribute from the module, raising SkipTest if it is
- not available."""
- with warnings.catch_warnings():
- if deprecated:
- warnings.filterwarnings("ignore", ".+ (module|package)",
- DeprecationWarning)
- try:
- attribute = getattr(module, name)
- except AttributeError:
- raise unittest.SkipTest("module %s has no attribute %s" % (
- module.__name__, name))
- else:
- return attribute
+def get_attribute(obj, name):
+ """Get an attribute, raising SkipTest if AttributeError is raised."""
+ try:
+ attribute = getattr(obj, name)
+ except AttributeError:
+ raise unittest.SkipTest("module %s has no attribute %s" % (
+ obj.__name__, name))
+ else:
+ return attribute
verbose = 1 # Flag set to 0 by regrtest.py