tests: Clean up cli imports even if --skipcli passed

This commit is contained in:
Cole Robinson 2013-08-06 14:58:43 -04:00
parent 7664840e68
commit 623edd1a84
2 changed files with 22 additions and 21 deletions

View File

@ -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")

View File

@ -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 #