Skip to content

Instantly share code, notes, and snippets.

View juliomistral's full-sized avatar

Julio A. Mistral juliomistral

  • San Francisco, CA
View GitHub Profile
@blaix
blaix / mock-with-arg-verification.py
Created March 30, 2012 23:25
Mocking new instance of class and verifying the arguments in python with flexmock
# Mock new instances of a class (verify that it's initialized with specific arguments)
# First argument to __new__ is the class, so pass `object` because we don't care about that part
flexmock(MyClass).should_receive('__new__').once.with_args(object, 'arg1', 'arg2').and_return(fake_object)
MyClass('wrong', 'arguments') # => MethodSignatureError
MyClass('arg1', 'arg2') # => <fake_object>
@blaix
blaix / settings.py
Created April 3, 2012 19:32
Stubbing django settings with Mock
SOME_SETTING = 'some value'