How to use the cleo.helpers.ProgressBar function in cleo

To help you get started, we’ve selected a few cleo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
def test_multiple_start(self):
        output = self.get_output_stream()
        bar = ProgressBar(output)
        bar.start()
        bar.advance()
        bar.start()

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

        self.assertEqual(expected, self.get_output_content(output))
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
' 10/10 [============================] 100%',
            ' 10/10 [============================] 100%'
        ])

        # max in construct, no format
        output = self.get_output_stream()
        bar = ProgressBar(output, 10)
        bar.start()
        bar.advance(10)
        bar.finish()

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

        # max in start, no format
        output = self.get_output_stream()
        bar = ProgressBar(output)
        bar.start(10)
        bar.advance(10)
        bar.finish()

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

        # max in construct, explicit format before
        output = self.get_output_stream()
        bar = ProgressBar(output, 10)
        bar.set_format('normal')
        bar.start()
        bar.advance(10)
        bar.finish()

        self.assertEqual(expected, self.get_output_content(output))
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
def test_percent_not_hundred_before_complete(self):
        output = self.get_output_stream()
        bar = ProgressBar(output, 200)
        bar.start()
        bar.display()
        bar.advance(199)
        bar.advance()

        expected = self.generate_output([
            '   0/200 [>---------------------------]   0%',
            '   0/200 [>---------------------------]   0%',
            ' 199/200 [===========================>]  99%',
            ' 200/200 [============================] 100%',
        ])

        self.assertEqual(expected, self.get_output_content(output))
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
def test_format(self):
        expected = self.generate_output([
            '  0/10 [>---------------------------]   0%',
            ' 10/10 [============================] 100%',
            ' 10/10 [============================] 100%'
        ])

        # max in construct, no format
        output = self.get_output_stream()
        bar = ProgressBar(output, 10)
        bar.start()
        bar.advance(10)
        bar.finish()

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

        # max in start, no format
        output = self.get_output_stream()
        bar = ProgressBar(output)
        bar.start(10)
        bar.advance(10)
        bar.finish()

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

        # max in construct, explicit format before
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
def test_display_without_start(self):
        output = self.get_output_stream()
        bar = ProgressBar(output, 50)
        bar.display()

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

        self.assertEqual(expected, self.get_output_content(output))
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
def test_regress(self):
        output = self.get_output_stream()
        bar = ProgressBar(output)
        bar.start()
        bar.advance()
        bar.advance()
        bar.advance(-1)

        expected = self.generate_output([
            '    0 [>---------------------------]',
            '    1 [->--------------------------]',
            '    2 [-->-------------------------]',
            '    1 [->--------------------------]'
        ])

        self.assertEqual(expected, self.get_output_content(output))
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
def test_advance(self):
        output = self.get_output_stream()
        bar = ProgressBar(output)
        bar.start()
        bar.advance()

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

        self.assertEqual(expected, self.get_output_content(output))
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
def test_finish_without_start(self):
        output = self.get_output_stream()
        bar = ProgressBar(output, 50)
        bar.finish()

        expected = self.generate_output(' 50/50 [============================] 100%')

        self.assertEqual(expected, self.get_output_content(output))
github sdispater / cleo / tests / helpers / test_progress_bar.py View on Github external
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))
github sdispater / cleo / cleo / styles / output_style.py View on Github external
def create_progress_bar(self, max=0):
        """
        Create a new progress bar

        :type max: int

        :rtype ProgressHelper
        """
        return ProgressBar(self, max)