MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / assertContained

Method assertContained

test/common.py:1150–1171  ·  view source on GitHub ↗
(self, values, string, additional_info='', regex=False)

Source from the content-addressed store, hash-verified

1148 self.assertFileContents(expected, read_file(actual), tofile=actual)
1149
1150 def assertContained(self, values, string, additional_info='', regex=False):
1151 if callable(string):
1152 string = string()
1153
1154 if regex:
1155 if type(values) is str:
1156 self.assertTrue(re.search(values, string, re.DOTALL), 'Expected regex "%s" to match on:\n%s' % (values, limit_size(string)))
1157 else:
1158 match_any = any(re.search(o, string, re.DOTALL) for o in values)
1159 self.assertTrue(match_any, 'Expected at least one of "%s" to match on:\n%s' % (values, limit_size(string)))
1160 return
1161
1162 if type(values) not in {list, tuple}:
1163 values = [values]
1164
1165 if not any(v in string for v in values):
1166 diff = difflib.unified_diff(values[0].split('\n'), string.split('\n'), fromfile='expected', tofile='actual')
1167 diff = ''.join(a.rstrip() + '\n' for a in diff)
1168 self.fail("Expected to find '%s' in '%s', diff:\n\n%s\n%s" % (
1169 limit_size(values[0]), limit_size(string), limit_size(diff),
1170 additional_info,
1171 ))
1172
1173 def assertNotContained(self, value, string, regex=False):
1174 if callable(value):

Callers 15

assertContainedIfMethod · 0.95
expect_failMethod · 0.95
assert_failMethod · 0.95
_build_and_runMethod · 0.95
test_jslib_ifdefMethod · 0.80
test_jslib_warningsMethod · 0.80
test_jslib_errorsMethod · 0.80

Calls 6

stringFunction · 0.90
limit_sizeFunction · 0.85
splitMethod · 0.80
failMethod · 0.80
typeEnum · 0.50
joinMethod · 0.45

Tested by 15

test_jslib_ifdefMethod · 0.64
test_jslib_warningsMethod · 0.64
test_jslib_errorsMethod · 0.64
test_jslib_preprocessMethod · 0.64
check_workingMethod · 0.64
test_firstrunMethod · 0.64
test_emccMethod · 0.64