How to stub time.sleep() in Python unit testing
You can use mock library in your tests. import time from mock import patch class MyTestCase(…): @patch(‘time.sleep’, return_value=None) def my_test(self, patched_time_sleep): time.sleep(666) # Should be instant