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

Method assertHasAttr

Lib/unittest/case.py:1380–1388  ·  view source on GitHub ↗
(self, obj, name, msg=None)

Source from the content-addressed store, hash-verified

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):

Calls 2

failMethod · 0.95
_formatMessageMethod · 0.95