Skip to content

Instantly share code, notes, and snippets.

@schmichael
Created March 22, 2012 23:44
Show Gist options
  • Save schmichael/2165530 to your computer and use it in GitHub Desktop.
Save schmichael/2165530 to your computer and use it in GitHub Desktop.
import mox
import time
# Pretend this is a web view and that calling time.time is something you actually want to test
def some_function_that_calls_time_twice():
start = time.time()
# do super expensive work here... hit a database maybe?
end = time.time()
class Tests(mox.MoxTestBase):
def test_something(self):
self.mox.StubOutWithMock(time, "time")
time.time().AndReturn(5)
time.time().AndReturn(6)
self.mox.ReplayAll()
some_function_that_calls_time_twice()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment