Skip to content

Commit b22169e

Browse files
committed
Ensure backend info is available in exception
1 parent 2219922 commit b22169e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/pyproject_hooks/_in_process/_in_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _build_backend():
7070
try:
7171
obj = import_module(mod_path)
7272
except ImportError:
73-
msg = "Cannot import {mod_path!r}"
73+
msg = f"Cannot import {mod_path!r}"
7474
raise BackendUnavailable(msg, traceback.format_exc())
7575

7676
if obj_path:

tests/test_call_hooks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ def get_hooks(pkg, **kwargs):
3434
def test_missing_backend_gives_exception():
3535
hooks = get_hooks("pkg1")
3636
with modified_env({"PYTHONPATH": ""}):
37-
with pytest.raises(BackendUnavailable):
37+
msg = "Cannot import 'buildsys'"
38+
with pytest.raises(BackendUnavailable, match=msg) as exc:
3839
hooks.get_requires_for_build_wheel({})
40+
assert exc.value.backend_name == "buildsys"
3941

4042

4143
def test_get_requires_for_build_wheel():

0 commit comments

Comments
 (0)