Example #1
0
 def test_unknown(self):
     if os.name == 'nt':
         speed = _speed_range(18, 20)
     else:
         speed = _speed_range(17, 19)
     expected = (
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         ('100 %', 'Done: 00:00:04', speed),
     )
     bar = Progress(maxval=None).start()
     for i, v in enumerate(range(10000, 100000, 10000)):
         time.sleep(0.5)
         bar.update(v)
         p, e, s = expected[i]
         self.assertEqual(bar.percentage, p)
         self.assertEqual(bar.ETA, e)
         self.assertIn(bar.speed, s)
     bar.stop()
     p, e, s = expected[i + 1]
     self.assertEqual(bar.percentage, p)
     self.assertEqual(bar.ETA, e)
     self.assertIn(bar.speed, s)
Example #2
0
    def test_basic(self):

        # These ranges may need tweaking to cater for especially slow
        # machines
        if os.name == 'nt':
            speed1 = _speed_range(18, 20)
            speed2 = _speed_range(20, 22)
        else:
            speed1 = _speed_range(16, 19)
            speed2 = _speed_range(20, 22)
        expected = (
            (' 10 %', 'ETA : 00:00:04', speed1),
            (' 20 %', 'ETA : 00:00:04', speed1),
            (' 30 %', 'ETA : 00:00:03', speed1),
            (' 40 %', 'ETA : 00:00:03', speed1),
            (' 50 %', 'ETA : 00:00:02', speed1),
            (' 60 %', 'ETA : 00:00:02', speed1),
            (' 70 %', 'ETA : 00:00:01', speed1),
            (' 80 %', 'ETA : 00:00:01', speed1),
            (' 90 %', 'ETA : 00:00:00', speed1),
            ('100 %', 'Done: 00:00:04', speed2),
        )
        bar = Progress(maxval=100000).start()
        for i, v in enumerate(range(10000, 100000, 10000)):
            time.sleep(0.5)
            bar.update(v)
            p, e, s = expected[i]
            self.assertEqual(bar.percentage, p)
            self.assertEqual(bar.ETA, e)
            self.assertIn(bar.speed, s)
        bar.stop()
        p, e, s = expected[i + 1]
        self.assertEqual(bar.percentage, p)
        self.assertEqual(bar.ETA, e)
        self.assertIn(bar.speed, s)
Example #3
0
 def test_unknown(self):
     if os.name == 'nt':
         speed = _speed_range(17, 20)
     else:
         speed = _speed_range(17, 19)
     expected = (
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         (' ?? %', 'ETA : ??:??:??', speed),
         ('100 %', 'Done: 00:00:04', speed),
     )
     bar = Progress(maxval=None).start()
     for i, v in enumerate(range(10000, 100000, 10000)):
         time.sleep(0.5)
         bar.update(v)
         p, e, s = expected[i]
         self.assertEqual(bar.percentage, p)
         self.assertEqual(bar.ETA, e)
         self.assertIn(bar.speed, s)
     bar.stop()
     p, e, s = expected[i + 1]
     self.assertEqual(bar.percentage, p)
     self.assertEqual(bar.ETA, e)
     self.assertIn(bar.speed, s)
Example #4
0
    def test_basic(self):

        # These ranges may need tweaking to cater for especially slow
        # machines
        if os.name == 'nt':
            speed1 = _speed_range(18, 20)
            speed2 = _speed_range(20, 22)
        else:
            speed1 = _speed_range(16, 19)
            speed2 = _speed_range(20, 22)
        expected = (
            (' 10 %', _eta_range(4, 7), speed1),
            (' 20 %', _eta_range(4, 7), speed1),
            (' 30 %', _eta_range(3, 4), speed1),
            (' 40 %', _eta_range(3, 3), speed1),
            (' 50 %', _eta_range(2, 2), speed1),
            (' 60 %', _eta_range(2, 2), speed1),
            (' 70 %', _eta_range(1, 1), speed1),
            (' 80 %', _eta_range(1, 1), speed1),
            (' 90 %', _eta_range(0, 0), speed1),
            ('100 %', _eta_range(4, 5, 'Done'), speed2),
        )
        bar = Progress(maxval=100000).start()
        for i, v in enumerate(range(10000, 100000, 10000)):
            time.sleep(0.5)
            bar.update(v)
            p, e, s = expected[i]
            self.assertEqual(bar.percentage, p)
            self.assertIn(bar.ETA, e, p)
            self.assertIn(bar.speed, s)
        bar.stop()
        p, e, s = expected[i + 1]
        self.assertEqual(bar.percentage, p)
        self.assertIn(bar.ETA, e, p)
        self.assertIn(bar.speed, s)