Beispiel #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))
Beispiel #2
0
    def test_stdout(self):
        bench = self.create_bench((1.0, 1.5, 2.0))

        with tempfile.NamedTemporaryFile(mode="w+") as tmp:
            bench.dump(tmp.name)
            stdout = self.run_command('convert', tmp.name, '--stdout')

        self.assertEqual(stdout,
                         tests.benchmark_as_json(bench))
Beispiel #3
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))
Beispiel #4
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')

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

        self.assertEqual(bench_json, tests.benchmark_as_json(result.bench))
Beispiel #5
0
    def test_dump_gzip(self):
        bench = self.create_dummy_benchmark()

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

            if six.PY3:
                fp = gzip.open(tmp_name, 'rt', encoding='utf-8')
            else:
                fp = gzip.open(tmp_name, 'rb')
            with fp:
                json = fp.read()

        expected = tests.benchmark_as_json(bench)
        self.assertEqual(json, expected)
Beispiel #6
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))
Beispiel #7
0
 def test_stdout(self):
     result = self.run_text_runner('--stdout', '--worker')
     self.assertEqual(result.stdout,
                      tests.benchmark_as_json(result.bench))