function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def testDataEmpty(self): output_dir = test.get_temp_dir() run_metadata = config_pb2.RunMetadata() graph = test.mock.MagicMock() graph.get_operations.return_value = [] profiles = pprof_profiler.get_profiles(graph, run_metadata) self.assertEqual(0, len(profiles)) profile_files = pprof_profile...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def testValidProfile(self): output_dir = test.get_temp_dir() run_metadata = config_pb2.RunMetadata() node1 = step_stats_pb2.NodeExecStats( node_name='Add/123', op_start_rel_micros=3, op_end_rel_micros=5, all_end_rel_micros=4) run_metadata = config_pb2.RunMetadata() ...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def testProfileWithWhileLoop(self): options = config_pb2.RunOptions() options.trace_level = config_pb2.RunOptions.FULL_TRACE run_metadata = config_pb2.RunMetadata() num_iters = 5 with self.cached_session() as sess: i = constant_op.constant(0) c = lambda i: math_ops.less(i, num_iters) ...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def fuzzy_compare(self, a, b, newlines_are_spaces=True, tabs_are_spaces=True, fuzzy_spacing=True, ignore_spaces=False, ignore_newlines=False, case_sensitive=False, leave_padding=False): """ Performs a fuzzy comparison of two strings. A fuzzy comparison is a...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def create_temp_cwd(self, copy_filenames=None): temp_dir = TemporaryWorkingDirectory() #Copy the files if requested. if copy_filenames is not None: self.copy_files_to(copy_filenames, dest=temp_dir.name) #Return directory handler return temp_dir
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def create_empty_notebook(self, path): nb = v4.new_notebook() with io.open(path, 'w', encoding='utf-8') as f: write(nb, f, 4)
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _get_files_path(self): #Get the relative path to this module in the IPython directory. names = self.__module__.split('.')[1:-1] names.append('files')
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def nbconvert(self, parameters, ignore_return_code=False, stdin=None): """ Run nbconvert as a shell command, listening for both Errors and non-zero return codes. Returns the tuple (stdout, stderr) of output produced during the nbconvert run. Parameters ---------- ...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _system_path(path_insertion): old_system_path = sys.path[:] sys.path = sys.path[0:1] + path_insertion + sys.path[1:] yield sys.path = old_system_path
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def _massage_proto_content(raw_proto_content): imports_substituted = raw_proto_content.replace( b'import "tests/protoc_plugin/protos/', b'import "beta_grpc_plugin_test/') package_statement_substituted = imports_substituted.replace( b'package grpc_protoc_plugin;', b'package beta_grpc_prot...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def __init__(self, payload_pb2, responses_pb2): self._condition = threading.Condition() self._paused = False self._fail = False self._payload_pb2 = payload_pb2 self._responses_pb2 = responses_pb2
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def pause(self): # pylint: disable=invalid-name with self._condition: self._paused = True yield with self._condition: self._paused = False self._condition.notify_all()
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def fail(self): # pylint: disable=invalid-name with self._condition: self._fail = True yield with self._condition: self._fail = False
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def UnaryCall(self, request, unused_rpc_context): response = self._responses_pb2.SimpleResponse() response.payload.payload_type = self._payload_pb2.COMPRESSABLE response.payload.payload_compressable = 'a' * request.response_size self._control() return response
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def StreamingInputCall(self, request_iter, unused_rpc_context): response = self._responses_pb2.StreamingInputCallResponse() aggregated_payload_size = 0 for request in request_iter: aggregated_payload_size += len(request.payload.payload_compressable) response.aggregated_payloa...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def HalfDuplexCall(self, request_iter, unused_rpc_context): responses = [] for request in request_iter: for parameter in request.response_parameters: response = self._responses_pb2.StreamingOutputCallResponse() response.payload.payload_type = self._payload_pb2...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def _CreateService(payload_pb2, responses_pb2, service_pb2): """Provides a servicer backend and a stub. The servicer is just the implementation of the actual servicer passed to the face player of the python RPC implementation; the two are detached. Yields: A (servicer_methods, stub) pair where servicer_...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def _CreateIncompleteService(service_pb2): """Provides a servicer backend that fails to implement methods and its stub. The servicer is just the implementation of the actual servicer passed to the face player of the python RPC implementation; the two are detached. Args: service_pb2: The service_pb2 modul...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def _streaming_output_request(requests_pb2): request = requests_pb2.StreamingOutputCallRequest() sizes = [1, 2, 3] request.response_parameters.add(size=sizes[0], interval_us=0) request.response_parameters.add(size=sizes[1], interval_us=0) request.response_parameters.add(size=sizes[2], interval_us=0)...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def setUp(self): self._directory = tempfile.mkdtemp(dir='.') self._proto_path = path.join(self._directory, _RELATIVE_PROTO_PATH) self._python_out = path.join(self._directory, _RELATIVE_PYTHON_OUT) os.makedirs(self._proto_path) os.makedirs(self._python_out) directories_p...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def _protoc(self): args = [ '', '--proto_path={}'.format(self._proto_path), '--python_out={}'.format(self._python_out), '--grpc_python_out=grpc_1_0:{}'.format(self._python_out), ] + list(self._proto_file_names) protoc_exit_code = protoc.main(args) ...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testUpDown(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2): self._requests_pb2.SimpleRequest(response_size=13)
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testUnaryCall(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): request = self._requests_pb2.SimpleRequest(response_size=13) response = stub.UnaryCall(request, test_constants.L...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testUnaryCallFutureExpired(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): request = self._requests_pb2.SimpleRequest(response_size=13) with methods.pause(): ...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testUnaryCallFutureFailed(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): request = self._requests_pb2.SimpleRequest(response_size=13) with methods.fail(): re...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testStreamingOutputCallExpired(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): request = _streaming_output_request(self._requests_pb2) with methods.pause(): r...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testStreamingOutputCallFailed(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): request = _streaming_output_request(self._requests_pb2) with methods.fail(): res...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testStreamingInputCallFuture(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): with methods.pause(): response_future = stub.StreamingInputCall.future( _...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testStreamingInputCallFutureCancelled(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): with methods.pause(): response_future = stub.StreamingInputCall.future( ...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testFullDuplexCall(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): responses = stub.FullDuplexCall( _full_duplex_request_iterator(self._requests_pb2), tes...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testFullDuplexCallCancelled(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): request_iterator = _full_duplex_request_iterator(self._requests_pb2) responses = stub.FullDuplexCa...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def testHalfDuplexCall(self): self._protoc() with _CreateService(self._payload_pb2, self._responses_pb2, self._service_pb2) as (methods, stub): def half_duplex_request_iterator(): request = self._requests_pb2.StreamingOutputCallRequest() ...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def wait(): # pylint: disable=invalid-name # Where's Python 3's 'nonlocal' statement when you need it? with condition: wait_cell[0] = True yield with condition: wait_cell[0] = False condition.notify_all()
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def wraps(original): def inner(f): f.__name__ = original.__name__ f.__doc__ = original.__doc__ f.__module__ = original.__module__ return f return inner
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def next(obj): return obj.next()
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _isidentifier(string): if string in keyword.kwlist: return False return regex.match(string)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _is_instance_mock(obj): # can't use isinstance on Mock objects because they override __class__ # The base class for all mocks is NonCallableMock return issubclass(type(obj), NonCallableMock)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _getsignature(func, skipfirst): if inspect is None: raise ImportError('inspect module not available') if inspect.isclass(func): func = func.__init__ # will have a self arg skipfirst = True elif not (inspect.ismethod(func) or inspect.isfunction(func)): func = func...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _check_signature(func, mock, skipfirst, instance=False): if not _callable(func): return result = _getsignature2(func, skipfirst, instance) if result is None: return signature, func = result # can't use self because "self" is common as an argument name # unfortunately even n...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _callable(obj): if isinstance(obj, ClassTypes): return True if getattr(obj, '__call__', None) is not None: return True return False
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _instance_callable(obj): """Given an object, return True if the object is callable. For classes, return True if instances would be callable.""" if not isinstance(obj, ClassTypes): # already an instance return getattr(obj, '__call__', None) is not None klass = obj # uses __bases_...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def mocksignature(func, mock=None, skipfirst=False): """ mocksignature(func, mock=None, skipfirst=False) Create a new function with the same signature as `func` that delegates to `mock`. If `skipfirst` is True the first argument is skipped, useful for methods where `self` needs to be omitted from t...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def assert_called_with(*args, **kwargs): return mock.assert_called_with(*args, **kwargs)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def assert_has_calls(*args, **kwargs): return mock.assert_has_calls(*args, **kwargs)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def reset_mock(): funcopy.method_calls = _CallList() funcopy.mock_calls = _CallList() mock.reset_mock() ret = funcopy.return_value if _is_instance_mock(ret) and not ret is mock: ret.reset_mock()
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _is_magic(name): return '__%s__' % name[2:-2] == name
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__(self, name): self.name = name
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__(self): self._sentinels = {}
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _copy(value): if type(value) in (dict, list, tuple, set): return type(value)(value) return value
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _mock_signature_property(name): _allowed_names.add(name) _the_name = '_mock_' + name def _get(self, name=name, _the_name=_the_name): sig = self._mock_signature if sig is None: return getattr(self, _the_name) return getattr(sig, name) def _set(self, value, name=nam...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __contains__(self, value): if not isinstance(value, list): return list.__contains__(self, value) len_value = len(value) len_self = len(self) if len_value > len_self: return False for i in range(0, len_self - len_value + 1): sub_list = self...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _check_and_set_parent(parent, value, name, new_name): if not _is_instance_mock(value): return False if ((value._mock_name or value._mock_new_name) or (value._mock_parent is not None) or (value._mock_new_parent is not None)): return False _parent = parent while _paren...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__(self, *args, **kwargs): pass
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __new__(cls, *args, **kw): # every instance has its own class # so we can create magic methods on the # class without stomping on other mocks new = type(cls.__name__, (cls,), {'__doc__': cls.__doc__}) instance = object.__new__(new) return instance
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def attach_mock(self, mock, attribute): """ Attach a mock as an attribute of this one, replacing its name and parent. Calls to the attached mock will be recorded in the `method_calls` and `mock_calls` attributes of this one.""" mock._mock_parent = None mock._mock_new_pare...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _mock_add_spec(self, spec, spec_set): _spec_class = None if spec is not None and not _is_list(spec): if isinstance(spec, ClassTypes): _spec_class = spec else: _spec_class = _get_class(spec) spec = dir(spec) __dict__ = sel...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __set_return_value(self, value): if self._mock_signature is not None: self._mock_signature.return_value = value else: self._mock_return_value = value _check_and_set_parent(self, value, None, '()')
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __class__(self): if self._spec_class is None: return type(self) return self._spec_class
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __get_side_effect(self): sig = self._mock_signature if sig is None: return self._mock_side_effect return sig.side_effect
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def reset_mock(self): "Restore the mock object to its initial state." self.called = False self.call_args = None self.call_count = 0 self.mock_calls = _CallList() self.call_args_list = _CallList() self.method_calls = _CallList() for child in self._mock_chi...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __getattr__(self, name): if name == '_mock_methods': raise AttributeError(name) elif self._mock_methods is not None: if name not in self._mock_methods or name in _all_magics: raise AttributeError("Mock object has no attribute %r" % name) elif _is_magic...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __dir__(self): """Filter the output of `dir(mock)` to only useful members. XXXX """ extras = self._mock_methods or [] from_type = dir(type(self)) from_dict = list(self.__dict__) if FILTER_DIR: from_type = [e for e in from_type if not e.startswith(...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __delattr__(self, name): if name in _all_magics and name in type(self).__dict__: delattr(type(self), name) if name not in self.__dict__: # for magic methods that are still MagicProxy objects and # not set on the instance itself return ...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _format_mock_failure_message(self, args, kwargs): message = 'Expected call: %s\nActual call: %s' expected_string = self._format_mock_call_signature(args, kwargs) call_args = self.call_args if len(call_args) == 3: call_args = call_args[1:] actual_string = self._for...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def assert_called_once_with(_mock_self, *args, **kwargs): """assert that the mock was called exactly once and with the specified arguments.""" self = _mock_self if not self.call_count == 1: msg = ("Expected to be called once. Called %s times." % self.call_c...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def assert_any_call(self, *args, **kwargs): """assert the mock has been called with the specified arguments. The assert passes if the mock has *ever* been called, unlike `assert_called_with` and `assert_called_once_with` that only pass if the call is the most recent one.""" kall...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _try_iter(obj): if obj is None: return obj if _is_exception(obj): return obj if _callable(obj): return obj try: return iter(obj) except TypeError: # XXXX backwards compatibility # but this will blow up on first call - so maybe we should fail early?...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__(self, spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, **kwargs): self.__dict__['_mock_return_value'] = return_value _super(CallableMixin, self).__init__...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __call__(_mock_self, *args, **kwargs): # can't use self in-case a function / method we are mocking uses self # in the signature _mock_self._mock_check_sig(*args, **kwargs) return _mock_self._mock_call(*args, **kwargs)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _dot_lookup(thing, comp, import_path): try: return getattr(thing, comp) except AttributeError: __import__(import_path) return getattr(thing, comp)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _is_started(patcher): # XXXX horrible return hasattr(patcher, 'is_local')
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__( self, getter, attribute, new, spec, create, mocksignature, spec_set, autospec, new_callable, kwargs ): if new_callable is not None: if new is not DEFAULT: raise ValueError( "Cannot use 'new' and 'new_callable' together...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __call__(self, func): if isinstance(func, ClassTypes): return self.decorate_class(func) return self.decorate_callable(func)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def decorate_callable(self, func): if hasattr(func, 'patchings'): func.patchings.append(self) return func @wraps(func) def patched(*args, **keywargs): # don't use a with here (backwards compatability with Python 2.4) extra_args = [] en...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __enter__(self): """Perform the patch.""" new, spec, spec_set = self.new, self.spec, self.spec_set autospec, kwargs = self.autospec, self.kwargs new_callable = self.new_callable self.target = self.getter() original, local = self.get_original() if new is DEFA...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _get_target(target): try: target, attribute = target.rsplit('.', 1) except (TypeError, ValueError): raise TypeError("Need a valid target to patch. You supplied: %r" % (target,)) getter = lambda: _importer(target) return getter, attribute
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _patch_multiple(target, spec=None, create=False, mocksignature=False, spec_set=None, autospec=False, new_callable=None, **kwargs ): """Perform multiple patches in a single call. It takes the object to be patched (either as an object or a string to fetch the object by importing) and k...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__(self, in_dict, values=(), clear=False, **kwargs): if isinstance(in_dict, basestring): in_dict = _importer(in_dict) self.in_dict = in_dict # support any argument supported by dict(...) constructor self.values = dict(values) self.values.update(kwargs) ...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _inner(*args, **kw): self._patch_dict() try: return f(*args, **kw) finally: self._unpatch_dict()
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def decorate_class(self, klass): for attr in dir(klass): attr_value = getattr(klass, attr) if (attr.startswith(patch.TEST_PREFIX) and hasattr(attr_value, "__call__")): decorator = _patch_dict(self.in_dict, self.values, self.clear) decorate...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _patch_dict(self): values = self.values in_dict = self.in_dict clear = self.clear try: original = in_dict.copy() except AttributeError: # dict like object with no copy method # must support iteration over keys original = {} ...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __exit__(self, *args): """Unpatch the dict.""" self._unpatch_dict() return False
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _clear_dict(in_dict): try: in_dict.clear() except AttributeError: keys = list(in_dict) for key in keys: del in_dict[key]
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _get_method(name, func): "Turns a callable object (like a mock) into a real function" def method(self, *args, **kw): return func(self, *args, **kw) method.__name__ = name return method
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _get_eq(self): def __eq__(other): ret_val = self.__eq__._mock_return_value if ret_val is not DEFAULT: return ret_val return self is other return __eq__
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __ne__(other): if self.__ne__._mock_return_value is not DEFAULT: return DEFAULT return self is not other
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _get_iter(self): def __iter__(): ret_val = self.__iter__._mock_return_value if ret_val is DEFAULT: return iter([]) # if ret_val was already an iterator, then calling iter on it should # return the iterator unchanged return iter(ret_val) return __iter__
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _set_return_value(mock, method, name): fixed = _return_values.get(name, DEFAULT) if fixed is not DEFAULT: method.return_value = fixed return return_calulator = _calculate_return_value.get(name) if return_calulator is not None: try: return_value = return_calulator...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__(self, *args, **kw): _super(MagicMixin, self).__init__(*args, **kw) self._mock_set_magics()
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __init__(self, name, parent): self.name = name self.parent = parent
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def create_mock(self): entry = self.name parent = self.parent m = parent._get_child_mock(name=entry, _new_name=entry, _new_parent=parent) setattr(parent, entry, m) _set_return_value(parent, m, entry) return m
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __eq__(self, other): return True
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __repr__(self): return '<ANY>'
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def _format_call_signature(name, args, kwargs): message = '%s(%%s)' % name formatted_args = '' args_string = ', '.join([repr(arg) for arg in args]) kwargs_string = ', '.join([ '%s=%r' % (key, value) for key, value in kwargs.items() ]) if args_string: formatted_args = args_string ...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __new__(cls, value=(), name=None, parent=None, two=False, from_kall=True): name = '' args = () kwargs = {} _len = len(value) if _len == 3: name, args, kwargs = value elif _len == 2: first, second = value if isinstanc...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __eq__(self, other): if other is ANY: return True try: len_other = len(other) except TypeError: return False self_name = '' if len(self) == 2: self_args, self_kwargs = self else: self_name, self_args, self_k...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __call__(self, *args, **kwargs): if self.name is None: return _Call(('', args, kwargs), name='()') name = self.name + '()' return _Call((self.name, args, kwargs), name=name, parent=self)
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]
def __repr__(self): if not self.from_kall: name = self.name or 'call' if name.startswith('()'): name = 'call%s' % name return name if len(self) == 2: name = 'call' args, kwargs = self else: name, args, kwarg...
mozilla/popcorn_maker
[ 34, 28, 34, 1, 1334919665 ]