Exemplo n.º 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)
Exemplo n.º 2
0
    def test_running_tests(self):
        stdout1 = StringIO()
        stderr1 = StringIO()
        runner1 = MockRunner('sfsf')
        main(stdout1,
             stderr1,
             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)
Exemplo n.º 3
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])
Exemplo n.º 4
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())
Exemplo n.º 5
0
    def test_single_success(self):
        stdout = io.StringIO()
        stderr = io.StringIO()
        runner = MockRunner('s')

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

        assert('\n' not in stderr.getvalue()[:-1])
        assert('foo' in stderr.getvalue())
Exemplo n.º 6
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())
Exemplo n.º 7
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", "bar"])
        assert(0 == rc)

        assert('\n' not in stderr.getvalue()[:-1])
        assert('foo' in stderr.getvalue())
        assert('bar' in stderr.getvalue())
Exemplo n.º 8
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)
Exemplo n.º 9
0
    def test_single_failure(self):
        stdout = io.StringIO()
        stderr = io.StringIO()
        runner = MockRunner('f')

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

        assert('\n' not in stderr.getvalue()[:-1])
        assert('foo' in stderr.getvalue())

        failures = stdout.getvalue().split('\n')[:-1]
        assert(1 == len(failures))
        assert('FAIL TEST foo CASE 1' in failures)
Exemplo n.º 10
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)
Exemplo n.º 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", "bar"])
        assert(1 == rc)

        assert('\n' not in stderr.getvalue()[:-1])
        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)