How to use the flexmock.FlexmockContainer.add_expectation function in flexmock

To help you get started, we’ve selected a few flexmock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github has207 / flexmock / flexmock.py View on Github external
def _create_placeholder_mock_for_proper_teardown(self, obj, name, original):
    """Ensures that the given function is replaced on teardown."""
    mock = Mock()
    mock._object = obj
    expectation = Expectation(obj, name=name, original=original)
    FlexmockContainer.add_expectation(mock, expectation)
github has207 / flexmock / flexmock.py View on Github external
def _create_expectation(self, obj, name, return_value=None):
    if self not in FlexmockContainer.flexmock_objects:
      FlexmockContainer.flexmock_objects[self] = []
    expectation = self._save_expectation(name, return_value)
    FlexmockContainer.add_expectation(self, expectation)
    if _isproperty(obj, name):
      self._update_property(expectation, name, return_value)
    elif (isinstance(obj, Mock) or
          hasattr(getattr(obj, name), '__call__') or
          _isclass(getattr(obj, name))):
      self._update_method(expectation, name)
    else:
      self._update_attribute(expectation, name, return_value)
    return expectation