tests: Remove useless read_file helper

This commit is contained in:
Cole Robinson 2018-06-12 11:37:02 -04:00
parent e12049b114
commit e0e6ac6956
2 changed files with 3 additions and 12 deletions

View File

@ -46,7 +46,7 @@ class TestClone(unittest.TestCase):
clone_disks_file=None):
"""Helper for comparing clone input/output from 2 xml files"""
infile = os.path.join(clonexml_dir, filebase + "-in.xml")
in_content = utils.read_file(infile)
in_content = open(infile).read()
if not conn:
conn = utils.URIs.open_testdriver_cached()
@ -100,7 +100,7 @@ class TestClone(unittest.TestCase):
"""Take the valid output xml and attempt to define it on the
connection to ensure we don't get any errors"""
outfile = os.path.join(clonexml_dir, filebase + "-out.xml")
outxml = utils.read_file(outfile)
outxml = open(outfile).read()
conn = utils.URIs.open_testdriver_cached()
utils.test_create(conn, outxml)

View File

@ -186,21 +186,12 @@ def test_create(testconn, xml, define_func="defineXML"):
pass
def read_file(filename):
"""Helper function to read a files contents and return them"""
f = open(filename, "r")
out = f.read()
f.close()
return out
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 clistate.regenerate_output:
open(filename, "w").write(actual_out)
expect_out = read_file(filename)
expect_out = open(filename).read()
diff = "".join(difflib.unified_diff(expect_out.splitlines(1),
actual_out.splitlines(1),