summaryrefslogtreecommitdiff
path: root/tests/__init__.py
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2017-02-23 18:47:57 -0500
committerCole Robinson <crobinso@redhat.com>2017-02-23 18:47:57 -0500
commit0055798d2127c7ef68c0fda5e06018a7693fb4cc (patch)
treeddd5573eae79045d5243dfff2637dde409fbeade /tests/__init__.py
parentdffb2aaa2de6c6819bc72a46d116919bcf2a6372 (diff)
downloadvirt-manager-0055798d2127c7ef68c0fda5e06018a7693fb4cc.tar.gz
tests: Move __init__ logic into functions, for clarity
Diffstat (limited to 'tests/__init__.py')
-rw-r--r--tests/__init__.py65
1 files changed, 39 insertions, 26 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index e2a5c375..19b5d3e9 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -32,39 +32,52 @@ 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
-rootLogger = logging.getLogger()
-for handler in rootLogger.handlers:
- rootLogger.removeHandler(handler)
+virtinstall = None
+virtclone = None
+virtconvert = None
+virtxml = None
-logging.basicConfig(level=logging.DEBUG,
- format="%(levelname)-8s %(message)s")
-if utils.get_debug():
- rootLogger.setLevel(logging.DEBUG)
-else:
- rootLogger.setLevel(logging.ERROR)
+def _setup_logging():
+ rootLogger = logging.getLogger()
+ for handler in rootLogger.handlers:
+ rootLogger.removeHandler(handler)
-_cleanup_imports = []
+ logging.basicConfig(level=logging.DEBUG,
+ format="%(levelname)-8s %(message)s")
+ if utils.get_debug():
+ rootLogger.setLevel(logging.DEBUG)
+ else:
+ rootLogger.setLevel(logging.ERROR)
-def _import(name, path):
- _cleanup_imports.append(path + "c")
- return imp.load_source(name, path)
+def _setup_cli_imports():
+ _cleanup_imports = []
-def _cleanup_imports_cb():
- for f in _cleanup_imports:
- if os.path.exists(f):
- os.unlink(f)
+ def _cleanup_imports_cb():
+ for f in _cleanup_imports:
+ if os.path.exists(f):
+ os.unlink(f)
-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")
+ def _import(name, path):
+ _cleanup_imports.append(path + "c")
+ return imp.load_source(name, path)
-# 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 = []
+ 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")
+
+
+_setup_logging()
+_setup_cli_imports()