Exemple #1
0
    def test_normal_function(self):
        iterable = range(100)
        timer = countdown.timer_for_iterable(iterable)
        self.assertTrue(timer.total_iterations == len(iterable))
        for i in iterable:
            timer.tick()

        output = self.trapped_stdout.getvalue()
        self.assertTrue('%d loops completed' % len(iterable) in output)
        self.assertTrue(timer.iterations_elapsed == len(iterable))
Exemple #2
0
    def test_normal_function(self):
        iterable = range(100)
        timer = countdown.timer_for_iterable(iterable)
        self.assertTrue(timer.total_iterations == len(iterable))
        for i in iterable:
            timer.tick()

        output = self.trapped_stdout.getvalue()
        self.assertTrue('%d loops completed' % len(iterable) in output)
        self.assertTrue(timer.iterations_elapsed == len(iterable))
Exemple #3
0
    def test_overrun(self):
        iterable = range(100)
        timer = countdown.timer_for_iterable(iterable)
        self.assertTrue(timer.total_iterations == len(iterable))
        for i in iterable:
            timer.tick()

        timer.tick()
        output = self.trapped_stdout.getvalue()
        sys.stdout = self.old_stdout
        self.assertTrue('Timer overrun!' in output)
Exemple #4
0
    def test_overrun(self):
        iterable = range(100)
        timer = countdown.timer_for_iterable(iterable)
        self.assertTrue(timer.total_iterations == len(iterable))
        for i in iterable:
            timer.tick()

        timer.tick()
        output = self.trapped_stdout.getvalue()
        sys.stdout = self.old_stdout
        self.assertTrue('Timer overrun!' in output)