Skip to content

Commit 1c98800

Browse files
authored
Fix bug when checking expected test output with regex=True. NFC (#17626)
The common case when expected_output is a string was not being handled here leading the inner loop here being run on each character of the string. See #17589
1 parent 654f45f commit 1c98800

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,13 +1199,15 @@ def _build_and_run(self, filename, expected_output, args=None, output_nicerizer=
11991199
interleaved_output=interleaved_output)
12001200
js_output = js_output.replace('\r\n', '\n')
12011201
if expected_output:
1202+
if type(expected_output) not in [list, tuple]:
1203+
expected_output = [expected_output]
12021204
try:
12031205
if assert_identical:
12041206
self.assertIdentical(expected_output, js_output)
12051207
elif assert_all or len(expected_output) == 1:
12061208
for o in expected_output:
12071209
if regex:
1208-
self.assertTrue(re.search(o, js_output), 'Expected regex "%s" to match on:\n%s' % (regex, js_output))
1210+
self.assertTrue(re.search(o, js_output), 'Expected regex "%s" to match on:\n%s' % (o, js_output))
12091211
else:
12101212
self.assertContained(o, js_output)
12111213
else:

0 commit comments

Comments
 (0)