setup: Use CLIState for setting --debug value
This commit is contained in:
parent
8ee2f62efe
commit
c05cd52772
5
setup.py
5
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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue