<commit_before>
from . import TestStdoutReader
import pyprogress
import re
from time import sleep


class TestProgressBar(TestStdoutReader):

    def tearDown(self):
        self.p.end()
        TestStdoutReader.tearDown(self)

    def test_progressbar_default(self):
        outputs = [
            '[                                        ] 0/10',
            '[\b]{47}\[#{4} {36}\] 1/10',
            '[\b]{47}\[#{8} {32}\] 2/10',
            '[\b]{47}\[#{12} {28}\] 3/10',
            '[\b]{47}\[#{16} {24}\] 4/10',
            '[\b]{47}\[#{20} {20}\] 5/10',
            '[\b]{47}\[#{24} {16}\] 6/10',
            '[\b]{47}\[#{28} {12}\] 7/10',
            '[\b]{47}\[#{32} {8}\] 8/10',
            '[\b]{47}\[#{36} {4}\] 9/10',
            '[\b]{47}\[#{40}\] 10/10'
        ]
        self.p = pyprogress.ProgressBar(10)
        self.p.begin()
        assert self.stdout.getvalue().strip() == outputs[0]
        self.stdout.truncate(0)

        for x in range(1, 11):
            self.p.inc()
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_inc2(self):
        outputs = [
            '[                                        ] 0/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########                                ] 2/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################                        ] 4/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################                ] 6/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################################        ] 8/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 10/10'
        ]
        self.p = pyprogress.ProgressBar(10)
        self.p.begin()
        assert self.stdout.getvalue().strip() == outputs[0]
        self.stdout.truncate(0)
        for x in range(1, 6):
            self.p.inc(2)
            assert self.stdout.getvalue().strip('\x00').strip() == outputs[x]
            self.stdout.truncate(0)

    def test_progressbar_expandpastlimit(self):
        outputs = [
            '[                                        ] 0/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########                                ] 2/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################                        ] 4/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################                ] 6/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################################        ] 8/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 10/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 12/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 14/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 16/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 18/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 20/10'
        ]
        self.p = pyprogress.ProgressBar(10)
        self.p.begin()
        assert self.stdout.getvalue().strip() == outputs[0]
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc(2)
            if self.stdout.getvalue().strip('\x00').strip() != outputs[x]:
                print >> sys.stderr, "\n"
                print >> sys.stderr, repr(outputs[x])
                print >> sys.stderr, repr(self.stdout.getvalue().strip())
            assert self.stdout.getvalue().strip('\x00').strip() == outputs[x]
            self.stdout.truncate(0)

    def test_progressbar_withname(self):
        outputs = [
            'ProgressBar [                                        ] 0/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[####                                    ] 1/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########                                ] 2/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[############                            ] 3/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################                        ] 4/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[####################                    ] 5/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################                ] 6/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[############################            ] 7/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################################        ] 8/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[####################################    ] 9/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 10/10'
        ]
        self.p = pyprogress.ProgressBar(10, name="ProgressBar")
        self.p.begin()
        assert self.stdout.getvalue().strip() == outputs[0]
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc()
            assert self.stdout.getvalue().strip('\x00').strip() == outputs[x]
            self.stdout.truncate(0)

    def test_progressbar_expandpastlimitwithname(self):
        outputs = [
            'ProgressBar [                                        ] 0/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########                                ] 2/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################                        ] 4/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################                ] 6/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[################################        ] 8/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 10/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 12/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 14/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 16/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 18/10',
            '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[########################################] 20/10'
        ]
        self.p = pyprogress.ProgressBar(10, name="ProgressBar")
        self.p.begin()
        assert self.stdout.getvalue().strip() == outputs[0]
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc(2)
            assert self.stdout.getvalue().strip('\x00').strip() == outputs[x]
            self.stdout.truncate(0)

    def test_progressbar_withruntime(self):
        outputs = [
            '0:00:00\.[0-9]{6} \[ {40}\] 0\/5 [0-9.]+\/s',
            '[\b]{65}0:00:01\.[0-9]{6} \[#{8} {32}\] 1\/5 [0-9.]+\/s',
            '[\b]{69}0:00:02\.[0-9]{6} \[#{16} {24}\] 2\/5 [0-9.]+\/s',  # \b length increases as items per second displays 1.000 instead of 0 because of zero division error
            '[\b]{69}0:00:03\.[0-9]{6} \[#{24} {16}\] 3\/5 [0-9.]+\/s',
            '[\b]{69}0:00:04\.[0-9]{6} \[#{32} {8}\] 4\/5 [0-9.]+\/s',
            '[\b]{69}0:00:05\.[0-9]{6} \[#{40}\] 5\/5 [0-9.]+\/s'
        ]
        self.p = pyprogress.ProgressBar(5, timecount=True)
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        sleep(1)
        for x in range(1, 6):
            self.p.inc(1)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)
            sleep(1)

    def test_progressbar_completionprediction(self):
        outputs = [
            '\[ {40}\] 0\/5 0\/s',
            '[\b]{51}4\.[0-9]{3} \[#{8} {32}\] 1\/5 [0-9.]+\/s',
            '[\b]{60}3\.[0-9]{3} \[#{16} {24}\] 2\/5 [0-9.]+\/s',  # \b length increases as items per second displays 1.000 instead of 0 because of zero division error and completionprediction shows
            '[\b]{60}2\.[0-9]{3} \[#{24} {16}\] 3\/5 [0-9.]+\/s',
            '[\b]{60}1\.[0-9]{3} \[#{32} {8}\] 4\/5 [0-9.]+\/s',
            '[\b]{60}0\.[0-9]{3} \[#{40}\] 5\/5 [0-9.]+\/s'
        ]
        self.p = pyprogress.ProgressBar(5, completionprediction=True)
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        sleep(1)
        for x in range(1, 6):
            self.p.inc(1)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)
            sleep(1)

    def test_progressbar_changeprogresschar(self):
        outputs = [
            '\[                                        \] 0\/10',
            '\b{47}\[----                                    \] 1\/10',
            '\b{47}\[--------                                \] 2\/10',
            '\b{47}\[------------                            \] 3\/10',
            '\b{47}\[----------------                        \] 4\/10',
            '\b{47}\[--------------------                    \] 5\/10',
            '\b{47}\[------------------------                \] 6\/10',
            '\b{47}\[----------------------------            \] 7\/10',
            '\b{47}\[--------------------------------        \] 8\/10',
            '\b{47}\[------------------------------------    \] 9\/10',
            '\b{47}\[----------------------------------------\] 10\/10'
        ]
        self.p = pyprogress.ProgressBar(10, progresschar='-')
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc(1)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_changewidth(self):
        outputs = [
            '\[ {80}\] 0\/8',
            '\b{86}\[#{10} {70}\] 1\/8',
            '\b{86}\[#{20} {60}\] 2\/8',
            '\b{86}\[#{30} {50}\] 3\/8',
            '\b{86}\[#{40} {40}\] 4\/8',
            '\b{86}\[#{50} {30}\] 5\/8',
            '\b{86}\[#{60} {20}\] 6\/8',
            '\b{86}\[#{70} {10}\] 7\/8',
            '\b{86}\[#{80}\] 8\/8',
        ]
        self.p = pyprogress.ProgressBar(8, width=80)<commit_msg>Updated remainder of main tests to use regex<commit_after>
from . import TestStdoutReader
import pyprogress
import re
import sys
from time import sleep


class TestProgressBar(TestStdoutReader):

    def tearDown(self):
        self.p.end()
        TestStdoutReader.tearDown(self)

    def test_progressbar_default(self):
        outputs = [
            '\[ {40}\] 0/10',
            '[\b]{47}\[#{4} {36}\] 1/10',
            '[\b]{47}\[#{8} {32}\] 2/10',
            '[\b]{47}\[#{12} {28}\] 3/10',
            '[\b]{47}\[#{16} {24}\] 4/10',
            '[\b]{47}\[#{20} {20}\] 5/10',
            '[\b]{47}\[#{24} {16}\] 6/10',
            '[\b]{47}\[#{28} {12}\] 7/10',
            '[\b]{47}\[#{32} {8}\] 8/10',
            '[\b]{47}\[#{36} {4}\] 9/10',
            '[\b]{47}\[#{40}\] 10/10'
        ]
        self.p = pyprogress.ProgressBar(10)
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)

        for x in range(1, 11):
            self.p.inc()
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_inc2(self):
        outputs = [
            '\[ {40}\] 0/10',
            '\b{47}\[#{8} {32}\] 2/10',
            '\b{47}\[#{16} {24}\] 4/10',
            '\b{47}\[#{24} {16}\] 6/10',
            '\b{47}\[#{32} {8}\] 8/10',
            '\b{47}\[#{40}\] 10/10'
        ]
        self.p = pyprogress.ProgressBar(10)
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        for x in range(1, 6):
            self.p.inc(2)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_expandpastlimit(self):
        outputs = [
            '\[ {40}\] 0/10',
            '\b{47}\[#{8} {32}\] 2/10',
            '\b{47}\[#{16} {24}\] 4/10',
            '\b{47}\[#{24} {16}\] 6/10',
            '\b{47}\[#{32} {8}\] 8/10',
            '\b{47}\[#{40}\] 10/10',
            '\b{48}\[#{40}\] 12/10',
            '\b{48}\[#{40}\] 14/10',
            '\b{48}\[#{40}\] 16/10',
            '\b{48}\[#{40}\] 18/10',
            '\b{48}\[#{40}\] 20/10'
        ]
        self.p = pyprogress.ProgressBar(10)
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc(2)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_withname(self):
        outputs = [
            'ProgressBar \[ {40}\] 0/10',
            '\b{47}\[#{4} {36}\] 1/10',
            '\b{47}\[#{8} {32}\] 2/10',
            '\b{47}\[#{12} {28}\] 3/10',
            '\b{47}\[#{16} {24}\] 4/10',
            '\b{47}\[#{20} {20}\] 5/10',
            '\b{47}\[#{24} {16}\] 6/10',
            '\b{47}\[#{28} {12}\] 7/10',
            '\b{47}\[#{32} {8}\] 8/10',
            '\b{47}\[#{36} {4}\] 9/10',
            '\b{47}\[#{40}\] 10/10'
        ]
        self.p = pyprogress.ProgressBar(10, name="ProgressBar")
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc()
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_expandpastlimitwithname(self):
        outputs = [
            'ProgressBar \[ {40}\] 0/10',
            '\b{47}\[#{8} {32}\] 2/10',
            '\b{47}\[#{16} {24}\] 4/10',
            '\b{47}\[#{24} {16}\] 6/10',
            '\b{47}\[#{32} {8}\] 8/10',
            '\b{47}\[#{40}\] 10/10',
            '\b{48}\[#{40}\] 12/10',
            '\b{48}\[#{40}\] 14/10',
            '\b{48}\[#{40}\] 16/10',
            '\b{48}\[#{40}\] 18/10',
            '\b{48}\[#{40}\] 20/10'
        ]
        self.p = pyprogress.ProgressBar(10, name="ProgressBar")
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc(2)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_withruntime(self):
        outputs = [
            '0:00:00\.[0-9]{6} \[ {40}\] 0\/5 [0-9.]+\/s',
            '[\b]{65}0:00:01\.[0-9]{6} \[#{8} {32}\] 1\/5 [0-9.]+\/s',
            '[\b]{69}0:00:02\.[0-9]{6} \[#{16} {24}\] 2\/5 [0-9.]+\/s',  # \b length increases as items per second displays 1.000 instead of 0 because of zero division error
            '[\b]{69}0:00:03\.[0-9]{6} \[#{24} {16}\] 3\/5 [0-9.]+\/s',
            '[\b]{69}0:00:04\.[0-9]{6} \[#{32} {8}\] 4\/5 [0-9.]+\/s',
            '[\b]{69}0:00:05\.[0-9]{6} \[#{40}\] 5\/5 [0-9.]+\/s'
        ]
        self.p = pyprogress.ProgressBar(5, timecount=True)
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        sleep(1)
        for x in range(1, 6):
            self.p.inc(1)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)
            sleep(1)

    def test_progressbar_completionprediction(self):
        outputs = [
            '\[ {40}\] 0\/5 0\/s',
            '[\b]{51}4\.[0-9]{3} \[#{8} {32}\] 1\/5 [0-9.]+\/s',
            '[\b]{60}3\.[0-9]{3} \[#{16} {24}\] 2\/5 [0-9.]+\/s',  # \b length increases as items per second displays 1.000 instead of 0 because of zero division error and completionprediction shows
            '[\b]{60}2\.[0-9]{3} \[#{24} {16}\] 3\/5 [0-9.]+\/s',
            '[\b]{60}1\.[0-9]{3} \[#{32} {8}\] 4\/5 [0-9.]+\/s',
            '[\b]{60}0\.[0-9]{3} \[#{40}\] 5\/5 [0-9.]+\/s'
        ]
        self.p = pyprogress.ProgressBar(5, completionprediction=True)
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        sleep(1)
        for x in range(1, 6):
            self.p.inc(1)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)
            sleep(1)

    def test_progressbar_changeprogresschar(self):
        outputs = [
            '\[ {40}\] 0\/10',
            '\b{47}\[-{4} {36}\] 1\/10',
            '\b{47}\[-{8} {32}\] 2\/10',
            '\b{47}\[-{12} {28}\] 3\/10',
            '\b{47}\[-{16} {24}\] 4\/10',
            '\b{47}\[-{20} {20}\] 5\/10',
            '\b{47}\[-{24} {16}\] 6\/10',
            '\b{47}\[-{28} {12}\] 7\/10',
            '\b{47}\[-{32} {8}\] 8\/10',
            '\b{47}\[-{36} {4}\] 9\/10',
            '\b{47}\[-{40}\] 10\/10'
        ]
        self.p = pyprogress.ProgressBar(10, progresschar='-')
        self.p.begin()
        assert re.match(outputs[0], self.stdout.getvalue().strip())
        self.stdout.truncate(0)
        for x in range(1, 11):
            self.p.inc(1)
            assert re.match(outputs[x], self.stdout.getvalue().strip('\x00').strip())
            self.stdout.truncate(0)

    def test_progressbar_changewidth(self):
        outputs = [
            '\[ {80}\] 0\/8',
            '\b{86}\[#{10} {70}\] 1\/8',
            '\b{86}\[#{20} {60}\] 2\/8',
            '\b{86}\[#{30} {50}\] 3\/8',
            '\b{86}\[#{40} {40}\] 4\/8',
            '\b{86}\[#{50} {30}\] 5\/8',
            '\b{86}\[#{60} {20}\] 6\/8',
            '\b{86}\[#{70} {10}\] 7\/8',
            '\b{86}\[#{80}\] 8\/8',
        ]
        self.p = pyprogress.ProgressBar(8, width=80)
{'fraction_non_alphanumeric': 0.3222858836313346, 'fraction_numerical': 0.07102637558036155, 'mean_word_length': 1.3477504638218925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5364187', 'n_tokens_mistral': 9697, 'n_tokens_neox': 9012, 'n_words': 930}