Add import_function method to test.test_support, and modify a number of

tests that expect to be skipped if imports fail or functions don't
exist to use import_function and import_module.  The ultimate goal is
to change regrtest to not skip automatically on ImportError.  Checking
in now to make sure the buldbots don't show any errors on platforms
I can't direct test on.
This commit is contained in:
R. David Murray 2009-03-30 19:04:00 +00:00
parent bb8cb0e192
commit 59beec326a
20 changed files with 78 additions and 41 deletions

View file

@ -55,6 +55,20 @@ def import_module(name, deprecated=False):
else:
return module
def import_function(module, name, deprecated=False):
with warnings.catch_warnings():
if deprecated:
warnings.filterwarnings("ignore", ".+ (module|package)",
DeprecationWarning)
try:
function = getattr(module, name)
except AttributeError:
raise unittest.SkipTest("No function named %s in module %s" % (
name, module.__name__))
else:
return function
verbose = 1 # Flag set to 0 by regrtest.py
use_resources = None # Flag set to [] by regrtest.py
max_memuse = 0 # Disable bigmem tests (they will still be run with