Skip to content

Instantly share code, notes, and snippets.

@dcramer
Created August 13, 2012 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcramer/3344286 to your computer and use it in GitHub Desktop.
Save dcramer/3344286 to your computer and use it in GitHub Desktop.
@mock.patch('modeldict.base.time')
def test_switch_creation(self, time_mod):
self.mydict['hello'] = 'foo'
self.assertEquals(self.cache.set.call_count, 2)
time_mod.time.return_value = 1344893511
print time_mod.mock_calls
print self.cache.set.mock_calls
self.cache.set.assert_any_call(self.mydict.cache_key, {u'hello': u'foo'})
self.cache.set.assert_any_call(self.mydict.last_updated_cache_key, time_mod.time.return_value)
AssertionError: set('ModelDict.last_updated:ModelDictModel:key', 1344893511) call not found
-------------------- >> begin captured stdout << ---------------------
<MagicMock name='time.time()' id='4525693200'>
[call.time(), call.time().__str__(), call.time(), call.time().__int__()]
[call('ModelDict:ModelDictModel:key', {u'hello': u'foo'}),
call('ModelDict.last_updated:ModelDictModel:key', 1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment