| 1378 | self.fail(self._formatMessage(msg, standardMsg)) |
| 1379 | |
| 1380 | def assertHasAttr(self, obj, name, msg=None): |
| 1381 | if not hasattr(obj, name): |
| 1382 | if isinstance(obj, types.ModuleType): |
| 1383 | standardMsg = f'module {obj.__name__!r} has no attribute {name!r}' |
| 1384 | elif isinstance(obj, type): |
| 1385 | standardMsg = f'type object {obj.__name__!r} has no attribute {name!r}' |
| 1386 | else: |
| 1387 | standardMsg = f'{type(obj).__name__!r} object has no attribute {name!r}' |
| 1388 | self.fail(self._formatMessage(msg, standardMsg)) |
| 1389 | |
| 1390 | def assertNotHasAttr(self, obj, name, msg=None): |
| 1391 | if hasattr(obj, name): |