def testSystem(self): with th.patch_time(starttime=100): self.assertEqual(time.time(), 100) self.assertEqual(time.clock(), 0) time.sleep(2) self.assertEqual(time.time(), 102) self.assertEqual(time.clock(), 2)
def setUp(self): self.addCleanup(testhelpers.patch_time().__enter__().__exit__)
def testPatchesAndUnpatched(self): getall = lambda: [getattr(time, a) for a in th.patch_time.ATTRS] orig = getall() with th.patch_time(): self.assertNotEqual(orig, getall()) self.assertEqual(orig, getall())