MCPcopy Create free account
hub / github.com/apple/coremltools / __getattr__

Method __getattr__

deps/protobuf/python/mox.py:386–417  ·  view source on GitHub ↗

Intercept attribute request on this object. If the attribute is a public class variable, it will be returned and not recorded as a call. If the attribute is not a variable, it is handled like a method call. The method name is checked against the set of mockable methods, and a n

(self, name)

Source from the content-addressed store, hash-verified

384 self._known_vars.add(method)
385
386 def __getattr__(self, name):
387 """Intercept attribute request on this object.
388
389 If the attribute is a public class variable, it will be returned and not
390 recorded as a call.
391
392 If the attribute is not a variable, it is handled like a method
393 call. The method name is checked against the set of mockable
394 methods, and a new MockMethod is returned that is aware of the
395 MockObject's state (record or replay). The call will be recorded
396 or replayed by the MockMethod's __call__.
397
398 Args:
399 # name: the name of the attribute being requested.
400 name: str
401
402 Returns:
403 Either a class variable or a new MockMethod that is aware of the state
404 of the mock (record or replay).
405
406 Raises:
407 UnknownMethodCallError if the MockObject does not mock the requested
408 method.
409 """
410
411 if name in self._known_vars:
412 return getattr(self._class_to_mock, name)
413
414 if name in self._known_methods:
415 return self._CreateMockMethod(name)
416
417 raise UnknownMethodCallError(name)
418
419 def __eq__(self, rhs):
420 """Provide custom logic to compare objects."""

Callers

nothing calls this directly

Calls 3

getattrFunction · 0.85
_CreateMockMethodMethod · 0.80

Tested by

no test coverage detected