예제 #1
0
  def testProgressNotCalled(self):
    func_counter = 0

    def Func() -> None:
      nonlocal func_counter
      func_counter += 1

    time.Sleep(42.0, progress_secs=108.0, progress_callback=Func)
    self.assertEqual(func_counter, 0)
    self.assertEqual(sum(self.sleeps), 42.0)
예제 #2
0
 def testNoProgress(self):
   time.Sleep(42.0)
   self.assertEqual(sum(self.sleeps), 42.0)
예제 #3
0
 def testZero(self):
   time.Sleep(0.0)
   self.assertEqual(sum(self.sleeps), 0.0)
예제 #4
0
 def Sleep(secs: float) -> None:
   time.Sleep(
       secs,
       progress_secs=opts.progress_interval,
       progress_callback=opts.progress_callback)
예제 #5
0
 def testNonPositiveProgress(self):
     with self.assertRaisesRegex(ValueError, "Non-positive"):
         time.Sleep(1.0, progress_secs=0.0)
예제 #6
0
 def testNegative(self):
     with self.assertRaisesRegex(ValueError, "Negative"):
         time.Sleep(-1.0)