Lines Matching refs:namespace
352 Given something that defines a namespace cls (class, object,
391 def stub_with(self, namespace, symbol, new_attribute):
392 original_attribute = getattr(namespace, symbol,
399 attribute_is_inherited = (hasattr(namespace, '__dict__') and
400 symbol not in namespace.__dict__)
404 newstub = (namespace, symbol, original_attribute, new_attribute)
406 setattr(namespace, symbol, new_attribute)
409 def stub_function(self, namespace, symbol):
411 self.stub_with(namespace, symbol, mock_attribute)
419 def stub_class(self, namespace, symbol):
420 attr = getattr(namespace, symbol)
422 self.stub_with(namespace, symbol, mock_class)
425 def stub_function_to_return(self, namespace, symbol, object_to_return):
428 @param namespace The namespace containing the function to stub out.
429 @param symbol The attribute within the namespace to stub out.
433 self.stub_with(namespace, symbol,
438 namespace, symbol, orig_attr, new_attr = stub
440 delattr(namespace, symbol)
442 setattr(namespace, symbol, orig_attr)
445 def unstub(self, namespace, symbol):
447 if (namespace, symbol) == (stub[0], stub[1]):