Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix running subcommands with hooks #208

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyperf/_process_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
12 changes: 12 additions & 0 deletions pyperf/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down