Exemplo n.º 1
0
    def test_stdout(self):
        bench = self.create_bench((1.0, 1.5, 2.0))

        with tests.temporary_file() as tmp_name:
            bench.dump(tmp_name)
            stdout = self.run_command('convert', tmp_name, '--stdout')

        self.assertEqual(stdout, tests.benchmark_as_json(bench))
Exemplo n.º 2
0
    def test_dump_gzip(self):
        bench = self.create_dummy_benchmark()

        with tests.temporary_file(suffix='.gz') as tmp_name:
            bench.dump(tmp_name)

            with gzip.open(tmp_name, 'rt', encoding='utf-8') as fp:
                json = fp.read()

        expected = tests.benchmark_as_json(bench)
        self.assertEqual(json, expected)
Exemplo n.º 3
0
    def test_pipe(self):
        rpipe, wpipe = create_pipe()
        with rpipe:
            with wpipe:
                arg = wpipe.to_subprocess()
                # Don't close the file descriptor, it is closed by
                # the Runner class
                wpipe._fd = None

                result = self.exec_runner('--pipe', str(arg), '--worker',
                                          '-l1', '-w1')

            with rpipe.open_text() as rfile:
                bench_json = rfile.read()

        self.assertEqual(bench_json, tests.benchmark_as_json(result.bench))