diff --git a/pyperf/_process_time.py b/pyperf/_process_time.py index f353f757..f18dee20 100644 --- a/pyperf/_process_time.py +++ b/pyperf/_process_time.py @@ -107,7 +107,7 @@ def load_hooks(metadata): import pyperf._hooks hook_managers = pyperf._hooks.instantiate_selected_hooks(hook_names) - metadata["hooks"] = ", ".join(hook_managers.values()) + metadata["hooks"] = ", ".join(hook_managers.keys()) else: hook_managers = {} diff --git a/pyperf/tests/test_runner.py b/pyperf/tests/test_runner.py index 1fa1594f..fc2fb58a 100644 --- a/pyperf/tests/test_runner.py +++ b/pyperf/tests/test_runner.py @@ -506,6 +506,18 @@ def test_bench_command(self): self.assertEqual(bench.get_metadata()['command'], ' '.join(map(shell_quote, args))) + def test_hook_command(self): + args = [sys.executable, '-c', 'pass'] + + runner = self.create_runner('-l1 -w0 -n1 --worker --hook _test_hook'.split()) + with tests.capture_stdout(): + bench = runner.bench_command('bench', args) + + self.assertEqual(bench.get_metadata()['command'], + ' '.join(map(shell_quote, args))) + self.assertEqual(bench.get_metadata()["hooks"], + "_test_hook") + def test_single_instance(self): runner1 = self.create_runner([]) # noqa with self.assertRaises(RuntimeError):