diff options
author | 2011-08-12 22:51:19 +0200 | |
---|---|---|
committer | 2011-08-12 22:51:19 +0200 | |
commit | 2ab344aeddbc7c068395ecf62089764c15f90a61 (patch) | |
tree | 45f92d23d2b0125b2f5ba00f9a33a04ede4c458d | |
parent | Fix test test library to match self-tests. (diff) | |
download | pms-test-suite-2ab344aeddbc7c068395ecf62089764c15f90a61.tar.gz pms-test-suite-2ab344aeddbc7c068395ecf62089764c15f90a61.tar.bz2 pms-test-suite-2ab344aeddbc7c068395ecf62089764c15f90a61.zip |
Use relative imports in module loader.
-rw-r--r-- | pmstestsuite/library/__init__.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py index 349b98b..eb5bade 100644 --- a/pmstestsuite/library/__init__.py +++ b/pmstestsuite/library/__init__.py @@ -63,7 +63,7 @@ class TestLibrary(ABCObject): # XXX: tests without a '.' in __init__? modname, clsname = t.rsplit('.', 1) modname = '%s.%s' % (self.modname, modname) - mod = __import__(modname, {}, {}, [clsname], 0) + mod = __import__(modname, fromlist=[clsname], globals=globals(), level=1) cls = getattr(mod, clsname) for i in cls.inst_all(thorough = self.thorough, undefined = self.undefined, short_name = t): @@ -118,8 +118,7 @@ def load_library(name, **kwargs): @raise TypeError: if no matching class is found in the module """ - modname = 'pmstestsuite.library.%s' % name - mod = __import__(modname, {}, {}, ['.'], 0) + mod = __import__(name, fromlist=['.'], globals=globals(), level=1) for k in dir(mod): modvar = getattr(mod, k) @@ -134,6 +133,6 @@ def load_library(name, **kwargs): pass else: raise TypeError('Unable to find a TestLibrary subclass in %s' - % modname) + % name) - return cls(modname, **kwargs) + return cls(name, **kwargs) |