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

Method assertHasAttr

Lib/test/support/testcase.py:19–27  ·  view source on GitHub ↗
(self, obj, name, msg=None)

Source from the content-addressed store, hash-verified

17 self.fail(self._formatMessage(msg, standardMsg))
18
19 def assertHasAttr(self, obj, name, msg=None):
20 if not hasattr(obj, name):
21 if isinstance(obj, types.ModuleType):
22 standardMsg = f'module {obj.__name__!r} has no attribute {name!r}'
23 elif isinstance(obj, type):
24 standardMsg = f'type object {obj.__name__!r} has no attribute {name!r}'
25 else:
26 standardMsg = f'{type(obj).__name__!r} object has no attribute {name!r}'
27 self.fail(self._formatMessage(msg, standardMsg))
28
29 def assertNotHasAttr(self, obj, name, msg=None):
30 if hasattr(obj, name):

Callers 15

testMethod · 0.45
test_dlopenflagsMethod · 0.45
test_sys_flagsMethod · 0.45
test_implementationMethod · 0.45
checkModuleMethod · 0.45
__init__Method · 0.45
test_slots_specialMethod · 0.45
test_properties_plusMethod · 0.45

Calls 4

hasattrFunction · 0.85
isinstanceFunction · 0.85
_formatMessageMethod · 0.80
failMethod · 0.45

Tested by

no test coverage detected