Beispiel #1
0
    def test_regress_below_min(self):
        output = self.get_output_stream()
        bar = ProgressBar(output, 10)
        bar.set_progress(1)
        bar.advance(-1)
        bar.advance(-1)

        expected = self.generate_output([
            '  1/10 [==>-------------------------]  10%',
            '  0/10 [>---------------------------]   0%'
        ])

        self.assertEqual(expected, self.get_output_content(output))
Beispiel #2
0
    def test_advance_over_max(self):
        output = self.get_output_stream()
        bar = ProgressBar(output, 10)
        bar.set_progress(9)
        bar.advance()
        bar.advance()

        expected = self.generate_output([[
            '  9/10 [=========================>--]  90%',
            ' 10/10 [============================] 100%',
            ' 11/11 [============================] 100%'
        ]])

        self.assertEqual(expected, self.get_output_content(output))
Beispiel #3
0
    def test_clear(self):
        output = self.get_output_stream()
        bar = ProgressBar(output, 50)
        bar.start()
        bar.set_progress(25)
        bar.clear()

        expected = self.generate_output([
            '  0/50 [>---------------------------]   0%',
            ' 25/50 [==============>-------------]  50%',
            '                                          '
        ])

        self.assertEqual(expected, self.get_output_content(output))
Beispiel #4
0
    def test_set_current_progress(self):
        output = self.get_output_stream()
        bar = ProgressBar(output, 50)
        bar.start()
        bar.display()
        bar.advance()
        bar.set_progress(15)
        bar.set_progress(25)

        expected = self.generate_output([
            '  0/50 [>---------------------------]   0%',
            '  0/50 [>---------------------------]   0%',
            '  1/50 [>---------------------------]   2%',
            ' 15/50 [========>-------------------]  30%',
            ' 25/50 [==============>-------------]  50%',
        ])

        self.assertEqual(expected, self.get_output_content(output))