X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=t%2Fmoe%2Futil.py;h=d287ff864c1230709b3172d658af4e1f3f157297;hb=a249fb797c925052e3ad692d887eb2004d66c455;hp=c7bbb5f4eea1dfdf8b68dde99cae8c0a01c02eaa;hpb=224eb93fad8979a07aeddc800ac73a84c775b27e;p=moe.git diff --git a/t/moe/util.py b/t/moe/util.py index c7bbb5f..d287ff8 100644 --- a/t/moe/util.py +++ b/t/moe/util.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os +import sys import os.path import shutil @@ -33,3 +34,10 @@ def remove_tree_contents(dir): shutil.rmtree(os.path.join(dir, f)) else: raise err + +def load_module(modname): + """Return the module `modname` (full name) if loaded, or try to import it. + Returns the module or raises `ImportError`.""" + if not sys.modules.has_key(modname): + __import__(modname) + return sys.modules[modname]