tests: Move __init__ logic into functions, for clarity

This commit is contained in:
Cole Robinson 2017-02-23 18:47:57 -05:00
parent dffb2aaa2d
commit 0055798d21
1 changed files with 46 additions and 33 deletions

View File

@ -32,8 +32,17 @@ reload(cliconfig)
from tests import utils
# Variable used to store a local iso or dir path to check for a distro
# Specified via 'python setup.py test_urls --path"
URLTEST_LOCAL_MEDIA = []
# Setup logging
virtinstall = None
virtclone = None
virtconvert = None
virtxml = None
def _setup_logging():
rootLogger = logging.getLogger()
for handler in rootLogger.handlers:
rootLogger.removeHandler(handler)
@ -46,25 +55,29 @@ if utils.get_debug():
else:
rootLogger.setLevel(logging.ERROR)
def _setup_cli_imports():
_cleanup_imports = []
def _import(name, path):
_cleanup_imports.append(path + "c")
return imp.load_source(name, path)
def _cleanup_imports_cb():
for f in _cleanup_imports:
if os.path.exists(f):
os.unlink(f)
def _import(name, path):
_cleanup_imports.append(path + "c")
return imp.load_source(name, path)
global virtinstall
global virtclone
global virtconvert
global virtxml
atexit.register(_cleanup_imports_cb)
virtinstall = _import("virtinstall", "virt-install")
virtclone = _import("virtclone", "virt-clone")
virtconvert = _import("virtconvert", "virt-convert")
virtxml = _import("virtxml", "virt-xml")
# Variable used to store a local iso or dir path to check for a distro
# Specified via 'python setup.py test_urls --path"
URLTEST_LOCAL_MEDIA = []
_setup_logging()
_setup_cli_imports()