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