Пример #1
0
 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)
Пример #2
0
 def setUp(self):
     self.addCleanup(testhelpers.patch_time().__enter__().__exit__)
Пример #3
0
 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())