コード例 #1
0
 def testSucceedsWithNoSamples(self):
     stream = six.StringIO()
     instance = publisher.PrettyPrintStreamPublisher(stream)
     instance.PublishSamples([])
     self.assertRegexpMatches(
         stream.getvalue(),
         r'^\s*-+PerfKitBenchmarker\sResults\sSummary-+\s*$')
コード例 #2
0
    def testWritesToStream(self):
        stream = six.StringIO()
        instance = publisher.PrettyPrintStreamPublisher(stream)
        samples = [{
            'test': 'testb',
            'metric': '1',
            'value': 1.0,
            'unit': 'MB',
            'metadata': {}
        }, {
            'test': 'testb',
            'metric': '2',
            'value': 14.0,
            'unit': 'MB',
            'metadata': {}
        }, {
            'test': 'testa',
            'metric': '3',
            'value': 47.0,
            'unit': 'us',
            'metadata': {}
        }]
        instance.PublishSamples(samples)

        value = stream.getvalue()
        self.assertRegexpMatches(value, re.compile(r'TESTA.*TESTB', re.DOTALL))
コード例 #3
0
 def testDefaultsToStdout(self):
     with mock.patch('sys.stdout') as mock_stdout:
         instance = publisher.PrettyPrintStreamPublisher()
         self.assertEqual(mock_stdout, instance.stream)