예제 #1
0
 def test_stop(self, _time):
     _time.return_value = 20.0
     t = Timer()
     t.started = 10.0
     t.stop()
     self.assertEqual(t.started, 10.0)
     self.assertEqual(t.stopped, 20.0)
예제 #2
0
 def test_stop(self, _time):
     _time.return_value = 20.0
     t = Timer()
     t.started = 10.0
     t.stop()
     self.assertEqual(t.started, 10.0)
     self.assertEqual(t.stopped, 20.0)
예제 #3
0
 def test_str(self):
     t = Timer()
     # not started
     self.assertEqual(str(t), 'not-running')
     # started but not stopped
     t.started = 1
     self.assertEqual(str(t), 'started: %d (running)' % t.started)
     # milliseconds
     t.started = 0.10
     t.stopped = 0.25
     self.assertEqual(str(t), '150 (ms)')
     # seconds
     t.started = 10.0
     t.stopped = 25.0
     self.assertEqual(str(t), '15.000 (seconds)')
     # minutes
     t.started = 10.0
     t.stopped = 100.0
     self.assertEqual(str(t), '1.500 (minutes)')
예제 #4
0
 def test_str(self):
     t = Timer()
     # not started
     self.assertEqual(str(t), 'idle')
     # started but not stopped
     t.started = 1
     self.assertEqual(str(t), 'started')
     # milliseconds
     t.started = 0.10
     t.stopped = 0.25
     self.assertEqual(str(t), '150 (ms)')
     # seconds
     t.started = 10.0
     t.stopped = 25.0
     self.assertEqual(str(t), '15.000 (seconds)')
     # minutes
     t.started = 10.0
     t.stopped = 100.0
     self.assertEqual(str(t), '1.500 (minutes)')
예제 #5
0
 def test_unicode(self):
     t = Timer()
     # not started
     self.assertEqual(unicode(t), 'not-running')
     # started but not stopped
     t.started = 1
     self.assertEqual(unicode(t), 'started: %d (running)' % t.started)
     # milliseconds
     t.started = 0.10
     t.stopped = 0.25
     self.assertEqual(unicode(t), '150 (ms)')
     # seconds
     t.started = 10.0
     t.stopped = 25.0
     self.assertEqual(unicode(t), '15.000 (seconds)')
     # minutes
     t.started = 10.0
     t.stopped = 100.0
     self.assertEqual(unicode(t), '1.500 (minutes)')
예제 #6
0
 def test_unicode(self):
     t = Timer()
     # not started
     self.assertEqual(unicode(t), 'idle')
     # started but not stopped
     t.started = 1
     self.assertEqual(unicode(t), 'started')
     # milliseconds
     t.started = 0.10
     t.stopped = 0.25
     self.assertEqual(unicode(t), '150 (ms)')
     # seconds
     t.started = 10.0
     t.stopped = 25.0
     self.assertEqual(unicode(t), '15.000 (seconds)')
     # minutes
     t.started = 10.0
     t.stopped = 100.0
     self.assertEqual(unicode(t), '1.500 (minutes)')
예제 #7
0
 def duration(self):
     t = Timer()
     t.started = 10.0
     t.stopped = 100.0
     self.assertEqual(t.duration(), 90.0)
예제 #8
0
 def test_duration(self):
     t = Timer()
     t.started = 10.0
     t.stopped = 100.0
     self.assertEqual(t.duration(), 90.0)