Unverified Commit 16ef312e authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Simplify TestCase.assertExpected() (#2815)



* Removing unnecessary variable.

* Refactoring common_utils.py to remove unused vars.

* Removing unused value and changing use of accept_output.
Co-authored-by: default avatarvfdev <vfdev.5@gmail.com>
Co-authored-by: default avatarFrancisco Massa <fvsmassa@gmail.com>
parent 73de9abe
......@@ -127,7 +127,6 @@ class TestCase(unittest.TestCase):
expected_file += "_" + subname
subname_output = " ({})".format(subname)
expected_file += "_expect.pkl"
expected = None
def accept_output(update_type):
print("Accepting {} for {}{}:\n\n{}".format(update_type, munged_id, subname_output, output))
......@@ -142,7 +141,8 @@ class TestCase(unittest.TestCase):
if e.errno != errno.ENOENT:
raise
elif ACCEPT:
return accept_output("output")
accept_output("output")
return
else:
raise RuntimeError(
("I got this output for {}{}:\n\n{}\n\n"
......@@ -150,13 +150,10 @@ class TestCase(unittest.TestCase):
"python {} {} --accept").format(munged_id, subname_output, output, __main__.__file__, munged_id))
if ACCEPT:
equal = False
try:
equal = self.assertEqual(output, expected, prec=prec)
self.assertEqual(output, expected, prec=prec)
except Exception:
equal = False
if not equal:
return accept_output("updated output")
accept_output("updated output")
else:
self.assertEqual(output, expected, prec=prec)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment