Ejemplo n.º 1
0
 def test_elapsed(self):
     # Test that the elapsed attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.elapsed, 0.0)
     for i in range(5):
         sw.start(); sw.stop()
         self.assertEqual(sw.elapsed, DELTA)
Ejemplo n.º 2
0
 def test_count(self):
     # Test that the count attribute is incremented correctly.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     for i in range(1, 6):
         sw.start(); sw.stop()
         self.assertEqual(sw.count, i)
Ejemplo n.º 3
0
 def test_running(self):
     # Test that the running flag is set and cleared correctly.
     sw = Stopwatch(verbose=False)
     self.assertFalse(sw.running)
     sw.start()
     self.assertTrue(sw.running)
     sw.stop()
     self.assertFalse(sw.running)
Ejemplo n.º 4
0
 def test_elapsed(self):
     # Test that the elapsed attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.elapsed, 0.0)
     for i in range(5):
         sw.start()
         sw.stop()
         self.assertEqual(sw.elapsed, DELTA)
Ejemplo n.º 5
0
 def test_count(self):
     # Test that the count attribute is incremented correctly.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     for i in range(1, 6):
         sw.start()
         sw.stop()
         self.assertEqual(sw.count, i)
Ejemplo n.º 6
0
 def test_count_while_running(self):
     # Test that count is calculated correctly while running.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     sw.start()
     self.assertEqual(sw.count, 1)
     sw.stop()
     self.assertEqual(sw.count, 1)
Ejemplo n.º 7
0
 def test_running(self):
     # Test that the running flag is set and cleared correctly.
     sw = Stopwatch(verbose=False)
     self.assertFalse(sw.running)
     sw.start()
     self.assertTrue(sw.running)
     sw.stop()
     self.assertFalse(sw.running)
Ejemplo n.º 8
0
 def test_total(self):
     # Test that the total attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.total, 0.0)
     for i in range(5):
         self.assertEqual(sw.total, i*DELTA)
         sw.start(); sw.stop()
     self.assertEqual(sw.total, (i+1)*DELTA)
Ejemplo n.º 9
0
 def test_count_while_running(self):
     # Test that count is calculated correctly while running.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     sw.start()
     self.assertEqual(sw.count, 1)
     sw.stop()
     self.assertEqual(sw.count, 1)
Ejemplo n.º 10
0
 def test_total(self):
     # Test that the total attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.total, 0.0)
     for i in range(5):
         self.assertEqual(sw.total, i * DELTA)
         sw.start()
         sw.stop()
     self.assertEqual(sw.total, (i + 1) * DELTA)
Ejemplo n.º 11
0
 def test_total_while_running(self):
     # Test that total is calculated correctly while running.
     sw = Stopwatch(timer=mock_time, verbose=False)
     sw.start()
     self.assertEqual(sw.total, DELTA)
     self.assertEqual(sw.total, 2 * DELTA)
     sw.stop()
     self.assertEqual(sw.total, 3 * DELTA)
     # Check it again, to be sure it's no longer increasing.
     self.assertEqual(sw.total, 3 * DELTA)
Ejemplo n.º 12
0
 def test_reset(self):
     # Test the reset method.
     sw = Stopwatch(verbose=False)
     for i in range(5):
         sw.start(); sw.stop()
     sw.reset()
     self.assertEqual(sw.count, 0)
     self.assertEqual(sw.total, 0.0)
     self.assertEqual(sw.elapsed, 0.0)
     self.assertFalse(sw.running)
Ejemplo n.º 13
0
 def test_total_while_running(self):
     # Test that total is calculated correctly while running.
     sw = Stopwatch(timer=mock_time, verbose=False)
     sw.start()
     self.assertEqual(sw.total, DELTA)
     self.assertEqual(sw.total, 2*DELTA)
     sw.stop()
     self.assertEqual(sw.total, 3*DELTA)
     # Check it again, to be sure it's no longer increasing.
     self.assertEqual(sw.total, 3*DELTA)
Ejemplo n.º 14
0
 def test_reset(self):
     # Test the reset method.
     sw = Stopwatch(verbose=False)
     for i in range(5):
         sw.start()
         sw.stop()
     sw.reset()
     self.assertEqual(sw.count, 0)
     self.assertEqual(sw.total, 0.0)
     self.assertEqual(sw.elapsed, 0.0)
     self.assertFalse(sw.running)