Created
March 22, 2012 23:44
-
-
Save schmichael/2165530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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