diff --git a/setup.py b/setup.py index 1fec2a0d8..1ae6a223d 100755 --- a/setup.py +++ b/setup.py @@ -390,6 +390,7 @@ class TestBaseCommand(distutils.core.Command): self._dir = os.getcwd() self.testfile = None self._force_verbose = False + self._external_coverage = False def finalize_options(self): if self.debug and "DEBUG_TESTS" not in os.environ: @@ -423,16 +424,16 @@ class TestBaseCommand(distutils.core.Command): cov = None if self.coverage: import coverage - # The latter is required to not give errors on f23, probably - # a temporary bug. - omit = ["/usr/*", "/*/tests/*", "/builddir/*"] + omit = ["/usr/*", "/*/tests/*"] cov = coverage.coverage(omit=omit) cov.erase() - cov.start() + if not self._external_coverage: + cov.start() import tests as testsmodule testsmodule.utils.clistate.regenerate_output = bool( self.regenerate_output) + testsmodule.utils.clistate.use_coverage = bool(cov) # This makes the test runner report results before exiting from ctrl-c unittest.installHandler() @@ -466,8 +467,11 @@ class TestBaseCommand(distutils.core.Command): sys.exit(1) if cov: - cov.stop() - cov.save() + if self._external_coverage: + cov.load() + else: + cov.stop() + cov.save() err = int(bool(len(result.failures) > 0 or len(result.errors) > 0)) @@ -516,6 +520,7 @@ class TestUI(TestBaseCommand): def run(self): self._testfiles = self._find_tests_in_dir("tests/uitests", []) self._force_verbose = True + self._external_coverage = True TestBaseCommand.run(self) diff --git a/tests/uitests/newvm.py b/tests/uitests/newvm.py index 151658f09..4013f8a61 100644 --- a/tests/uitests/newvm.py +++ b/tests/uitests/newvm.py @@ -16,8 +16,6 @@ class NewVM(uiutils.UITestCase): ################### def _open_create_wizard(self): - conn_label = "test testdriver.xml" - uiutils.find_pattern(self.app.root, conn_label, "table cell") b = uiutils.find_pattern(self.app.root, "New", "push button", wait_for_focus=True) b.click() diff --git a/tests/uitests/utils.py b/tests/uitests/utils.py index e3685bf25..7b88629fb 100644 --- a/tests/uitests/utils.py +++ b/tests/uitests/utils.py @@ -90,12 +90,14 @@ class DogtailApp(object): stdout = open(os.devnull) stderr = open(os.devnull) - self._proc = subprocess.Popen([sys.executable, - os.path.join(os.getcwd(), "virt-manager"), - "--test-first-run", "--no-fork", "--connect", self.uri] + - extra_opts, - stdout=stdout, stderr=stderr) + cmd = [sys.executable] + if tests.utils.clistate.use_coverage: + cmd += ["-m", "coverage", "run", "--append"] + cmd += [os.path.join(os.getcwd(), "virt-manager"), + "--test-first-run", "--no-fork", "--connect", self.uri] + cmd += extra_opts + self._proc = subprocess.Popen(cmd, stdout=stdout, stderr=stderr) self._root = dogtail.tree.root.application("virt-manager") def stop(self): diff --git a/tests/utils.py b/tests/utils.py index 2d594a0a2..32642adba 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -32,6 +32,7 @@ class _CLIState(object): """ def __init__(self): self.regenerate_output = False + self.use_coverage = False clistate = _CLIState()