예제 #1
0
def test_report_output():
    """
    Just to cover output-related code, this trivial feature itself is not
    tested otherwise.
    """
    with open(os.devnull, 'w') as f:
        for enable_colors in (False, True):
            r = Report(enable_colors, f)
            r.add('Foobar')
            r.output()
예제 #2
0
    def test():
        # Pre-process content
        report = Report(enable_colors=False)
        content = reindent_content(tc)
        check_file_content(report, tc.filename, content)
        records = [(tc.filename, ) + rec for rec in tc.records]

        def fmt_records(records):
            return ('\n'.join(
                '  {}:{}:{}: {}'.format(*rec)
                for rec in records) if records else '  <no report>')

        assert report.records == records, (
            'For the following source:\n'
            '{}\n'
            'Got the following report:\n'
            '{}\n'
            'But the following was expected instead:\n'
            '{}'.format(
                '\n'.join('    {}'.format(line)
                          for line in content.split('\n')),
                fmt_records(report.records), fmt_records(records)))