MCPcopy Index your code
hub / github.com/python/cpython / assertNotRegex

Method assertNotRegex

Lib/unittest/case.py:1447–1459  ·  view source on GitHub ↗

Fail the test if the text matches the regular expression.

(self, text, unexpected_regex, msg=None)

Source from the content-addressed store, hash-verified

1445 raise self.failureException(msg)
1446
1447 def assertNotRegex(self, text, unexpected_regex, msg=None):
1448 """Fail the test if the text matches the regular expression."""
1449 if isinstance(unexpected_regex, (str, bytes)):
1450 unexpected_regex = re.compile(unexpected_regex)
1451 match = unexpected_regex.search(text)
1452 if match:
1453 standardMsg = 'Regex matched: %r matches %r in %r' % (
1454 text[match.start() : match.end()],
1455 unexpected_regex.pattern,
1456 text)
1457 # _formatMessage ensures the longMessage option is respected
1458 msg = self._formatMessage(msg, standardMsg)
1459 raise self.failureException(msg)
1460
1461 def _tail_type_check(self, s, tails, msg):
1462 if not isinstance(tails, tuple):

Calls 5

_formatMessageMethod · 0.95
compileMethod · 0.45
searchMethod · 0.45
startMethod · 0.45
endMethod · 0.45