Exemple #1
0
    def test_running_tests(self):
        stdout1 = StringIO()
        stderr1 = StringIO()
        runner1 = MockRunner('sfsf')
        main(stdout1, stderr1, None, runner1, lambda: 80,
             [__name__, 'runtests', 'foo'])

        stdout2 = StringIO()
        stderr2 = StringIO()
        runner2 = MockRunner('sfsf')
        run_tests(stdout2, stderr2, runner2, lambda: 80, ['foo'])

        assert (stdout1.getvalue() == stdout2.getvalue())
        assert (stderr1.getvalue() == stderr2.getvalue())
        assert (runner1.commands == runner2.commands)
Exemple #2
0
 def test_driver_with_executor(self):
     runner = MockRunner('')
     test, errors = run_one((runner, ['x', 'y'], 'foo', 'foo'))
     assert ('foo' == test)
     assert (1 == len(runner.commands))
     assert (['x', 'y', 'foo', '1'] == runner.commands[0])
     assert (not errors)
Exemple #3
0
 def test_driver_with_no_cases(self):
     runner = MockRunner('')
     test, errors = run_one((runner, [], 'foo', 'foo'))
     assert ('foo' == test)
     assert (1 == len(runner.commands))
     assert (['foo', '1'] == runner.commands[0])
     assert (not errors)
Exemple #4
0
 def test_driver_with_one_failure(self):
     runner = MockRunner('f')
     test, errors = run_one((runner, [], 'foo', 'foo'))
     assert ('foo' == test)
     assert (2 == len(runner.commands))
     assert (['foo', '1'] == runner.commands[0])
     assert (['foo', '2'] == runner.commands[1])
     assert (1 == len(errors))
     assert (1 in errors)
Exemple #5
0
    def test_tty_has_no_newlines(self):
        stdout = io.StringIO()
        stderr = mock.Mock(wraps=io.StringIO())
        stderr.isatty.return_value = True
        runner = MockRunner('s')

        rc = run_tests(stdout, stderr, runner, [], lambda: 80,
                       [["foo", "foo"]])
        assert (0 == rc)
        assert ('\n' not in stderr.getvalue()[:-1])
Exemple #6
0
    def test_single_success(self):
        stdout = io.StringIO()
        stderr = io.StringIO()
        runner = MockRunner('s')

        rc = run_tests(stdout, stderr, runner, [], lambda: 80,
                       [["foo", "foo"]])
        assert (0 == rc)

        assert ('foo' in stderr.getvalue())
Exemple #7
0
 def test_driver_with_four_successes(self):
     runner = MockRunner('ssss')
     test, errors = run_one((runner, [], 'foo', 'foo'))
     assert ('foo' == test)
     assert (5 == len(runner.commands))
     assert (['foo', '1'] == runner.commands[0])
     assert (['foo', '2'] == runner.commands[1])
     assert (['foo', '3'] == runner.commands[2])
     assert (['foo', '4'] == runner.commands[3])
     assert (['foo', '5'] == runner.commands[4])
     assert (not errors)
Exemple #8
0
    def test_two_drivers_four_successes_each(self):
        stdout = io.StringIO()
        stderr = io.StringIO()
        runner = MockRunner('ssss')

        rc = run_tests(stdout, stderr, runner, [], lambda: 80,
                       [["foo", "foo"], ["bar", "bar"]])
        assert (0 == rc)

        assert ('foo' in stderr.getvalue())
        assert ('bar' in stderr.getvalue())
Exemple #9
0
 def test_driver_with_mixed_successes_failures(self):
     runner = MockRunner('sfsf')
     test, errors = run_one((runner, [], 'foo', 'foo'))
     assert ('foo' == test)
     assert (5 == len(runner.commands))
     assert (['foo', '1'] == runner.commands[0])
     assert (['foo', '2'] == runner.commands[1])
     assert (['foo', '3'] == runner.commands[2])
     assert (['foo', '4'] == runner.commands[3])
     assert (['foo', '5'] == runner.commands[4])
     assert (2 == len(errors))
     assert (2 in errors)
     assert (4 in errors)
Exemple #10
0
    def test_single_failure(self):
        stdout = io.StringIO()
        stderr = io.StringIO()
        runner = MockRunner('f')

        rc = run_tests(stdout, stderr, runner, [], lambda: 80,
                       [["foo", "foo"]])
        assert (1 == rc)

        assert ('foo' in stderr.getvalue())

        failures = stdout.getvalue().split('\n')[:-1]
        assert (1 == len(failures))
        assert ('FAIL TEST foo CASE 1' in failures)
Exemple #11
0
    def test_two_drivers_mixed_successes(self):
        stdout = io.StringIO()
        stderr = io.StringIO()
        runner = MockRunner('sfsf')

        rc = run_tests(stdout, stderr, runner, [], lambda: 80,
                       [["foo", "foo"], ["bar", "bar"]])
        assert (1 == rc)

        assert ('foo' in stderr.getvalue())
        assert ('bar' in stderr.getvalue())

        failures = stdout.getvalue().split('\n')[:-1]
        assert (4 == len(failures))
        assert ('FAIL TEST foo CASE 2' in failures)
        assert ('FAIL TEST foo CASE 4' in failures)
        assert ('FAIL TEST bar CASE 2' in failures)
        assert ('FAIL TEST bar CASE 4' in failures)
Exemple #12
0
 def test_one_success_one_failure(self):
     runner = MockRunner('sf')
     assert (RunResult.SUCCESS == runner('foo'))
     assert (RunResult.FAILURE == runner('bar'))
     assert (RunResult.NO_SUCH_CASE == runner('bam'))
     assert (['foo', 'bar', 'bam'] == runner.commands)
Exemple #13
0
 def test_one_success(self):
     runner = MockRunner('s')
     assert (RunResult.SUCCESS == runner('foo'))
     assert (RunResult.NO_SUCH_CASE == runner('bar'))
     assert (['foo', 'bar'] == runner.commands)
Exemple #14
0
 def test_no_cases(self):
     runner = MockRunner('')
     assert (RunResult.NO_SUCH_CASE == runner('foo'))
     assert (['foo'] == runner.commands)