How to use the flexmock.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 _save_expectation(self, name, return_value=None):
    if name in [x.name for x in
                FlexmockContainer.flexmock_objects[self]]:
      expectation = [x for x in FlexmockContainer.flexmock_objects[self]
                     if x.name == name][0]
      expectation = Expectation(
          self._object, name=name, return_value=return_value,
          original=expectation.__dict__.get('original'))
    else:
      expectation = Expectation(
          self._object, name=name, return_value=return_value)
    return expectation
github has207 / flexmock / flexmock.py View on Github external
def _retrieve_or_create_expectation(self, method, return_value=None):
    if method in [x.method for x in FlexmockContainer.flexmock_objects[self]]:
      expectation = [x for x in FlexmockContainer.flexmock_objects[self]
                     if x.method == method][0]
      expectation = Expectation(
          self._object, name=method, return_value=return_value,
          original_method=expectation.original_method)
    else:
      expectation = Expectation(
          self._object, name=method, return_value=return_value)
    return expectation
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 _save_expectation(self, name, return_value=None):
    if name in [x.name for x in
                FlexmockContainer.flexmock_objects[self]]:
      expectation = [x for x in FlexmockContainer.flexmock_objects[self]
                     if x.name == name][0]
      expectation = Expectation(
          self._object, name=name, return_value=return_value,
          original=expectation.__dict__.get('original'))
    else:
      expectation = Expectation(
          self._object, name=name, return_value=return_value)
    return expectation
github has207 / flexmock / flexmock.py View on Github external
def _retrieve_or_create_expectation(self, method, return_value=None):
    if method in [x.method for x in FlexmockContainer.flexmock_objects[self]]:
      expectation = [x for x in FlexmockContainer.flexmock_objects[self]
                     if x.method == method][0]
      expectation = Expectation(
          self._object, name=method, return_value=return_value,
          original_method=expectation.original_method)
    else:
      expectation = Expectation(
          self._object, name=method, return_value=return_value)
    return expectation