From 623edd1a84870cb5ae3ccd16fdc230e876ee1051 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 6 Aug 2013 14:58:43 -0400 Subject: [PATCH] tests: Clean up cli imports even if --skipcli passed --- tests/__init__.py | 21 +++++++++++++++++++++ tests/clitest.py | 22 +--------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 7cb43ca3f..fb48cf2fa 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -14,6 +14,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA. +import atexit +import imp import logging import os @@ -46,3 +48,22 @@ if utils.get_debug(): rootLogger.setLevel(logging.DEBUG) else: rootLogger.setLevel(logging.ERROR) + +_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) + +atexit.register(_cleanup_imports_cb) +virtinstall = _import("virtinstall", "virt-install") +virtimage = _import("virtimage", "virt-image") +virtclone = _import("virtclone", "virt-clone") +virtconvert = _import("virtconvert", "virt-convert") diff --git a/tests/clitest.py b/tests/clitest.py index b29bb54e0..00f1809ad 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -15,7 +15,6 @@ # MA 02110-1301 USA. import atexit -import imp import logging import os import shlex @@ -28,6 +27,7 @@ import StringIO import virtinst.cli +from tests import virtinstall, virtimage, virtclone, virtconvert from tests import utils os.environ["VIRTCONV_TEST_NO_DISK_CONVERSION"] = "1" @@ -129,26 +129,6 @@ test_files = { } -_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) - - -atexit.register(_cleanup_imports_cb) -virtinstall = _import("virtinstall", "virt-install") -virtimage = _import("virtimage", "virt-image") -virtclone = _import("virtclone", "virt-clone") -virtconvert = _import("virtconvert", "virt-convert") - ###################### # Test class helpers #