From b22169e849f787b8fc962259fe32e314970d378b Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 22 Feb 2023 23:31:34 +0000 Subject: [PATCH] Ensure backend info is available in exception --- src/pyproject_hooks/_in_process/_in_process.py | 2 +- tests/test_call_hooks.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyproject_hooks/_in_process/_in_process.py b/src/pyproject_hooks/_in_process/_in_process.py index 635cbba..9070b65 100644 --- a/src/pyproject_hooks/_in_process/_in_process.py +++ b/src/pyproject_hooks/_in_process/_in_process.py @@ -70,7 +70,7 @@ def _build_backend(): try: obj = import_module(mod_path) except ImportError: - msg = "Cannot import {mod_path!r}" + msg = f"Cannot import {mod_path!r}" raise BackendUnavailable(msg, traceback.format_exc()) if obj_path: diff --git a/tests/test_call_hooks.py b/tests/test_call_hooks.py index d20c13a..5aa7673 100644 --- a/tests/test_call_hooks.py +++ b/tests/test_call_hooks.py @@ -34,8 +34,10 @@ def get_hooks(pkg, **kwargs): def test_missing_backend_gives_exception(): hooks = get_hooks("pkg1") with modified_env({"PYTHONPATH": ""}): - with pytest.raises(BackendUnavailable): + msg = "Cannot import 'buildsys'" + with pytest.raises(BackendUnavailable, match=msg) as exc: hooks.get_requires_for_build_wheel({}) + assert exc.value.backend_name == "buildsys" def test_get_requires_for_build_wheel():