diff --git a/setup.py b/setup.py index 4cd1b1f9..4ab6b3b1 100755 --- a/setup.py +++ b/setup.py @@ -397,8 +397,6 @@ class TestBaseCommand(distutils.core.Command): self._external_coverage = False def finalize_options(self): - if self.debug and "DEBUG_TESTS" not in os.environ: - os.environ["DEBUG_TESTS"] = "1" if self.only: # Can do --only many-devices to match on the cli testcase # for "virt-install-many-devices", despite the actual test @@ -438,6 +436,9 @@ class TestBaseCommand(distutils.core.Command): testsmodule.utils.clistate.regenerate_output = bool( self.regenerate_output) testsmodule.utils.clistate.use_coverage = bool(cov) + testsmodule.utils.clistate.debug = bool(self.debug) + testsmodule.setup_logging() + testsmodule.setup_cli_imports() # This makes the test runner report results before exiting from ctrl-c unittest.installHandler() diff --git a/tests/__init__.py b/tests/__init__.py index 0482e6f0..99bf38ad 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -38,7 +38,7 @@ virtconvert = None virtxml = None -def _setup_logging(): +def setup_logging(): rootLogger = logging.getLogger() for handler in rootLogger.handlers: rootLogger.removeHandler(handler) @@ -46,13 +46,13 @@ def _setup_logging(): logging.basicConfig(level=logging.DEBUG, format="%(levelname)-8s %(message)s") - if utils.get_debug(): + if utils.clistate.debug: rootLogger.setLevel(logging.DEBUG) else: rootLogger.setLevel(logging.ERROR) -def _setup_cli_imports(): +def setup_cli_imports(): _cleanup_imports = [] def _cleanup_imports_cb(): @@ -73,7 +73,3 @@ def _setup_cli_imports(): virtclone = _import("virtclone", "virt-clone") virtconvert = _import("virtconvert", "virt-convert") virtxml = _import("virtxml", "virt-xml") - - -_setup_logging() -_setup_cli_imports() diff --git a/tests/test_urls.py b/tests/test_urls.py index 3864f776..878fb0ad 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -106,7 +106,7 @@ hvmguest.os.os_type = "hvm" xenguest = Guest(testconn) xenguest.os.os_type = "xen" -meter = util.make_meter(quiet=not utils.get_debug()) +meter = util.make_meter(quiet=not utils.clistate.debug) def _storeForDistro(fetcher, guest): diff --git a/tests/uitests/utils.py b/tests/uitests/utils.py index 1f7d61e8..b813f528 100644 --- a/tests/uitests/utils.py +++ b/tests/uitests/utils.py @@ -339,7 +339,7 @@ class VMMDogtailApp(object): def open(self, extra_opts=None): extra_opts = extra_opts or [] - if tests.utils.get_debug(): + if tests.utils.clistate.debug: stdout = sys.stdout stderr = sys.stderr extra_opts.append("--debug") diff --git a/tests/utils.py b/tests/utils.py index c97a5929..e81f19b7 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -33,6 +33,7 @@ class _CLIState(object): def __init__(self): self.regenerate_output = False self.use_coverage = False + self.debug = False clistate = _CLIState() @@ -64,11 +65,6 @@ uri_lxc = uri_test + _capsprefix + "lxc.xml,lxc" uri_vz = uri_test + _capsprefix + "vz.xml,vz" -def get_debug(): - return ("DEBUG_TESTS" in os.environ and - os.environ["DEBUG_TESTS"] == "1") - - def _make_uri(base, connver=None, libver=None): if connver: base += ",connver=%s" % connver