Skip to content

Commit 16ef312

Browse files
datumboxvfdev-5fmassa
authored
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: vfdev <vfdev.5@gmail.com> Co-authored-by: Francisco Massa <fvsmassa@gmail.com>
1 parent 73de9ab commit 16ef312

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

test/common_utils.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def remove_prefix_suffix(text, prefix, suffix):
127127
expected_file += "_" + subname
128128
subname_output = " ({})".format(subname)
129129
expected_file += "_expect.pkl"
130-
expected = None
131130

132131
def accept_output(update_type):
133132
print("Accepting {} for {}{}:\n\n{}".format(update_type, munged_id, subname_output, output))
@@ -142,21 +141,19 @@ def accept_output(update_type):
142141
if e.errno != errno.ENOENT:
143142
raise
144143
elif ACCEPT:
145-
return accept_output("output")
144+
accept_output("output")
145+
return
146146
else:
147147
raise RuntimeError(
148148
("I got this output for {}{}:\n\n{}\n\n"
149149
"No expect file exists; to accept the current output, run:\n"
150150
"python {} {} --accept").format(munged_id, subname_output, output, __main__.__file__, munged_id))
151151

152152
if ACCEPT:
153-
equal = False
154153
try:
155-
equal = self.assertEqual(output, expected, prec=prec)
154+
self.assertEqual(output, expected, prec=prec)
156155
except Exception:
157-
equal = False
158-
if not equal:
159-
return accept_output("updated output")
156+
accept_output("updated output")
160157
else:
161158
self.assertEqual(output, expected, prec=prec)
162159

0 commit comments

Comments
 (0)