mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
tests: Rework how we pass command line objects down to test data
This commit is contained in:
parent
89945118df
commit
044d93d471
3
setup.py
3
setup.py
@ -431,7 +431,8 @@ class TestBaseCommand(distutils.core.Command):
|
||||
cov.start()
|
||||
|
||||
import tests as testsmodule
|
||||
testsmodule.utils.REGENERATE_OUTPUT = bool(self.regenerate_output)
|
||||
testsmodule.utils.clistate.regenerate_output = bool(
|
||||
self.regenerate_output)
|
||||
|
||||
# This makes the test runner report results before exiting from ctrl-c
|
||||
unittest.installHandler()
|
||||
|
@ -252,7 +252,8 @@ class Command(object):
|
||||
|
||||
# Generate test files that don't exist yet
|
||||
filename = self.compare_file
|
||||
if utils.REGENERATE_OUTPUT or not os.path.exists(filename):
|
||||
if (utils.clistate.regenerate_output or
|
||||
not os.path.exists(filename)):
|
||||
open(filename, "w").write(output)
|
||||
|
||||
if "--print-diff" in self.argv and output.count("\n") > 3:
|
||||
|
@ -22,12 +22,19 @@ import virtinst
|
||||
import virtinst.cli
|
||||
import virtinst.uri
|
||||
|
||||
# DON'T EDIT THIS. Use 'setup.py test --regenerate-output'
|
||||
REGENERATE_OUTPUT = False
|
||||
|
||||
# pylint: disable=protected-access
|
||||
# Access to protected member, needed to unittest stuff
|
||||
|
||||
class _CLIState(object):
|
||||
"""
|
||||
Class containing any bits passed in from setup.py
|
||||
"""
|
||||
def __init__(self):
|
||||
self.regenerate_output = False
|
||||
clistate = _CLIState()
|
||||
|
||||
|
||||
_capsprefix = ",caps=%s/tests/capabilities-xml/" % os.getcwd()
|
||||
_domcapsprefix = ",domcaps=%s/tests/capabilities-xml/" % os.getcwd()
|
||||
|
||||
@ -175,7 +182,7 @@ def read_file(filename):
|
||||
def diff_compare(actual_out, filename=None, expect_out=None):
|
||||
"""Compare passed string output to contents of filename"""
|
||||
if not expect_out:
|
||||
if not os.path.exists(filename) or REGENERATE_OUTPUT:
|
||||
if not os.path.exists(filename) or clistate.regenerate_output:
|
||||
open(filename, "w").write(actual_out)
|
||||
expect_out = read_file(filename)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user