Пример #1
0
 def _render_results(self, results, **kwargs):
     """Render a given set of result objects into their related string form."""
     with tempfile.TemporaryFile() as f:
         with reporters.FancyReporter(out=PlainTextFormatter(f),
                                      **kwargs) as reporter:
             for result in sorted(results):
                 reporter.report(result)
         f.seek(0)
         output = f.read().decode()
         return output
Пример #2
0
 def test_replay(self, capsys):
     result = ProfileWarning('profile warning: foo')
     for reporter_cls in (reporters.BinaryPickleStream,
                          reporters.JsonStream):
         with tempfile.NamedTemporaryFile() as f:
             out = PlainTextFormatter(f)
             with reporter_cls(out) as reporter:
                 reporter.report(result)
             with patch('sys.argv',
                        self.args + ['-R', 'StrReporter', f.name]):
                 with pytest.raises(SystemExit) as excinfo:
                     self.script()
                 out, err = capsys.readouterr()
                 assert not err
                 assert out == 'profile warning: foo\n'
Пример #3
0
 def execute_main(self, *a, **kw):
     config = self.parse(*a, **kw)
     out = PlainTextFormatter(BytesIO())
     ret = config.main_func(config, out, out)
     return ret, config, out
Пример #4
0
 def __init__(self):
     PlainTextFormatter.__init__(self, ListStream([]))
     self.reset = Reset()
     self.bold = Bold()
     self.first_prefix = [None]
Пример #5
0
 def mk_reporter(self, **kwargs):
     out = PlainTextFormatter(sys.stdout)
     return self.reporter_cls(out, **kwargs)
Пример #6
0
 def __init__(self):
     PlainTextFormatter.__init__(self, ListStream([]))
     self.reset = Reset()
     self.bold = Bold()
     self.first_prefix = [None]