MCPcopy Index your code
hub / github.com/RustPython/RustPython / assertIsInstance

Method assertIsInstance

Lib/unittest/case.py:1334–1342  ·  view source on GitHub ↗

Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

(self, obj, cls, msg=None)

Source from the content-addressed store, hash-verified

1332 self.fail(self._formatMessage(msg, standardMsg))
1333
1334 def assertIsInstance(self, obj, cls, msg=None):
1335 """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
1336 default message."""
1337 if not isinstance(obj, cls):
1338 if isinstance(cls, tuple):
1339 standardMsg = f'{safe_repr(obj)} is not an instance of any of {cls!r}'
1340 else:
1341 standardMsg = f'{safe_repr(obj)} is not an instance of {cls!r}'
1342 self.fail(self._formatMessage(msg, standardMsg))
1343
1344 def assertNotIsInstance(self, obj, cls, msg=None):
1345 """Included for symmetry with assertIsInstance."""

Calls 4

failMethod · 0.95
_formatMessageMethod · 0.95
isinstanceFunction · 0.85
safe_reprFunction · 0.85