Beispiel #1
0
 def test_cancel(self):
     m = ConsoleMonitor()
     with fetch_std_streams():
         m.start('task A', total_work=10)
         self.assertFalse(m.is_cancelled())
         m.cancel()
         self.assertTrue(m.is_cancelled())
Beispiel #2
0
 def test_cancel(self):
     m = ConsoleMonitor()
     with fetch_std_streams():
         m.start('task A', total_work=10)
         self.assertFalse(m.is_cancelled())
         m.cancel()
         self.assertTrue(m.is_cancelled())
Beispiel #3
0
    def test_console_monitor_with_progress_bar(self):
        m = ConsoleMonitor(progress_bar_size=10)
        with fetch_std_streams() as (stdout, stderr):
            m.start('task A', total_work=10)
            m.progress(work=1)
            m.progress(work=5, msg='phase 1')
            m.progress(msg='phase 2')
            m.progress(work=4)
            m.progress()
            m.done()
        actual_stdout = stdout.getvalue()
        expected_stdout = 'task A: started\n' + \
                          'task A: [#---------]  10% \n' + \
                          'task A: [######----]  60% phase 1\n' + \
                          'task A: phase 2\n' + \
                          'task A: [##########] 100% \n' + \
                          'task A: in progress...\n' + \
                          'task A: done\n'

        self.assertEqual(actual_stdout, expected_stdout)
        self.assertEqual(stderr.getvalue(), '')
Beispiel #4
0
    def test_console_monitor_with_progress_bar(self):
        m = ConsoleMonitor(progress_bar_size=10)
        with fetch_std_streams() as (stdout, stderr):
            m.start('task A', total_work=10)
            m.progress(work=1)
            m.progress(work=5, msg='phase 1')
            m.progress(msg='phase 2')
            m.progress(work=4)
            m.progress()
            m.done()
        actual_stdout = stdout.getvalue()
        expected_stdout = 'task A: started\n' + \
                          'task A: [#---------]  10% \n' + \
                          'task A: [######----]  60% phase 1\n' + \
                          'task A: phase 2\n' + \
                          'task A: [##########] 100% \n' + \
                          'task A: in progress...\n' + \
                          'task A: done\n'

        self.assertEqual(actual_stdout, expected_stdout)
        self.assertEqual(stderr.getvalue(), '')
Beispiel #5
0
    def test_console_monitor(self):
        m = ConsoleMonitor()
        with fetch_std_streams() as (stdout, stderr):
            m.start('task A', total_work=10)
            m.progress(work=1)
            m.progress(work=5, msg='phase 1')
            m.progress(msg='phase 2')
            m.progress(work=4)
            m.progress()
            m.done()
        actual_stdout = stdout.getvalue()
        expected_stdout = 'task A: started\n' + \
                          'task A:  10%\n' + \
                          'task A:  60% phase 1\n' + \
                          'task A: phase 2\n' + \
                          'task A: 100%\n' + \
                          'task A: progress\n' + \
                          'task A: done\n'

        self.assertEqual(actual_stdout, expected_stdout)
        self.assertEqual(stderr.getvalue(), '')
        self.assertTrue(True)
Beispiel #6
0
 def test_label_required(self):
     monitor = ConsoleMonitor()
     with fetch_std_streams():
         with self.assertRaises(ValueError):
             # "ValueError: label must be given"
             monitor.start('', total_work=10)
Beispiel #7
0
 def test_label_required(self):
     monitor = ConsoleMonitor()
     with fetch_std_streams():
         with self.assertRaises(ValueError):
             # "ValueError: label must be given"
             monitor.start('', total_work=10)