Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.
(self, obj, cls, msg=None)
| 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.""" |