Ejemplo n.º 1
0
def cli_no_file(cli):
    """Test that providing no header or config prints usage message."""
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['-v', '-d'])
    assert str(error) == '2'
    assert out[0].startswith('usage:')
Ejemplo n.º 2
0
def cli_no_file(cli):
    """Test that providing no header or config prints usage message."""
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['-v', '-d'])
    assert str(error) == '2'
    assert out[0].startswith('usage:')
Ejemplo n.º 3
0
def cli_file_dont_existing(cli):
    """Test if a file is missing"""
    config = os.path.join(os.path.dirname(__file__), 'sprint2.yml')
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['404.h', config])
    assert str(error) == '2'
    assert out[0].startswith('Unknown file(s): 404.h')
Ejemplo n.º 4
0
def cli_file_dont_existing(cli):
    """Test if a file is missing"""
    config = os.path.join(os.path.dirname(__file__), 'sprint2.yml')
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['404.h', config])
    assert str(error) == '2'
    assert out[0].startswith('Unknown file(s): 404.h')
Ejemplo n.º 5
0
    def run(self, reporter=auto_reporter,
            full_tracebacks=False, fail_fast=False,
            debugger=False, no_capture=False, keyboard_interrupt=False):
        """Run all tests in this collection.

        :param reporter:
            An instance of :class:`~attest.reporters.AbstractReporter` or a
            callable returning something implementing that API (not
            enforced).
        :param full_tracebacks:
            Control if the call stack of Attest is hidden in tracebacks.
        :param fail_fast:
            Stop after the first failure.
        :param debugger:
            Enter PDB when tests fail.
        :param keyboard_interrupt:
            Let KeyboardInterrupt exceptions (CTRL+C) propagate.

        .. versionchanged:: 0.6 Added `full_tracebacks` and `fail_fast`.

        """
        assertions, statistics.assertions = statistics.assertions, 0
        if not isinstance(reporter, AbstractReporter):
            reporter = reporter()
        reporter.begin(self._tests)
        for test in self:
            result = TestResult(test=test, full_tracebacks=full_tracebacks,
                                debugger=debugger)
            result.time = time()
            try:
                out, err = [], []
                if no_capture:
                    if test() is False:
                        raise AssertionError('test() is False')
                else:
                    with capture_output() as (out, err):
                        if test() is False:
                            raise AssertionError('test() is False')
            except KeyboardInterrupt:
                if keyboard_interrupt:
                    raise
                else:
                    break
            except BaseException, e:
                result.time = time() - result.time
                result.error = e
                result.stdout, result.stderr = out, err
                result.exc_info = sys.exc_info()
                reporter.failure(result)
                if fail_fast:
                    break
            else:
                result.time = time() - result.time
                result.stdout, result.stderr = out, err
                reporter.success(result)