Example #1
0
    def test_colored_bar(self):
        """
        Colored progressbar
        """
        progress = ProgressHelper()
        output = self.get_output_stream(decorated=True)
        progress.set_bar_character("<comment>=</comment>")
        progress.start(output, 50)
        progress.display()
        progress.advance()
        progress.advance()
        progress.advance()
        progress.advance()
        progress.advance()

        output.get_stream().seek(0)
        self.assertEqual(
            self.generate_output("  0/50 [>---------------------------]   0%")
            + self.generate_output("  1/50 [>---------------------------]   2%")
            + self.generate_output("  2/50 [\x1b[33m=\x1b[0m>--------------------------]   4%")
            + self.generate_output("  3/50 [\x1b[33m=\x1b[0m>--------------------------]   6%")
            + self.generate_output("  4/50 [\x1b[33m=\x1b[0m\x1b[33m=\x1b[0m>-------------------------]   8%")
            + self.generate_output("  5/50 [\x1b[33m=\x1b[0m\x1b[33m=\x1b[0m>-------------------------]  10%"),
            output.get_stream().read().decode(),
        )
Example #2
0
    def test_colored_bar(self):
        """
        Colored progressbar
        """
        progress = ProgressHelper()
        output = self.get_output_stream(decorated=True)
        progress.set_bar_character('<comment>=</comment>')
        progress.start(output, 50)
        progress.display()
        progress.advance()
        progress.advance()
        progress.advance()
        progress.advance()
        progress.advance()

        output.get_stream().seek(0)
        self.assertEqual(
            self.generate_output('  0/50 [>---------------------------]   0%')
            +
            self.generate_output('  1/50 [>---------------------------]   2%')
            + self.generate_output(
                '  2/50 [\x1b[33m=\x1b[0m>--------------------------]   4%') +
            self.generate_output(
                '  3/50 [\x1b[33m=\x1b[0m>--------------------------]   6%') +
            self.generate_output(
                '  4/50 [\x1b[33m=\x1b[0m\x1b[33m=\x1b[0m>-------------------------]   8%'
            ) + self.generate_output(
                '  5/50 [\x1b[33m=\x1b[0m\x1b[33m=\x1b[0m>-------------------------]  10%'
            ),
            output.get_stream().read().decode())
Example #3
0
    def test_customizations(self):
        """
        Customizing ProgressHelper should be possible
        """
        progress = ProgressHelper()
        progress.set_bar_width(10)
        progress.set_bar_character("_")
        progress.set_empty_bar_character(" ")
        progress.set_progress_character("/")
        progress.set_display_format(" %current%/%max% [%bar%] %percent%%")

        output = self.get_output_stream()
        progress.start(output, 10)
        progress.advance()

        output.get_stream().seek(0)
        self.assertEqual(self.generate_output("  1/10 [_/        ]  10%"), output.get_stream().read().decode())
Example #4
0
    def test_customizations(self):
        """
        Customizing ProgressHelper should be possible
        """
        progress = ProgressHelper()
        progress.set_bar_width(10)
        progress.set_bar_character('_')
        progress.set_empty_bar_character(' ')
        progress.set_progress_character('/')
        progress.set_display_format(' %current%/%max% [%bar%] %percent%%')

        output = self.get_output_stream()
        progress.start(output, 10)
        progress.advance()

        output.get_stream().seek(0)
        self.assertEqual(self.generate_output('  1/10 [_/        ]  10%'),
                         output.get_stream().read().decode())