Skip to content

Commit 5ec2615

Browse files
committed
Include name of missing hook in HookMissing
1 parent 69c8010 commit 5ec2615

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pep517/wrappers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def __init__(self, backend_name, backend_path, message):
3737

3838
class HookMissing(Exception):
3939
"""Will be raised on missing hooks."""
40+
def __init__(self, hook_name):
41+
super(HookMissing, self).__init__(hook_name)
42+
self.hook_name = hook_name
4043

4144

4245
class UnsupportedOperation(Exception):
@@ -245,7 +248,7 @@ def _call_hook(self, hook_name, kwargs):
245248
message=data.get('backend_error', '')
246249
)
247250
if data.get('hook_missing'):
248-
raise HookMissing()
251+
raise HookMissing(hook_name)
249252
return data['return_val']
250253

251254

tests/test_hook_fallbacks.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ def test_prepare_metadata_for_build_wheel_no_fallback():
4545

4646
with TemporaryDirectory() as metadatadir:
4747
with modified_env({'PYTHONPATH': BUILDSYS_PKGS}):
48-
with pytest.raises(HookMissing):
48+
with pytest.raises(HookMissing) as exc_info:
4949
hooks.prepare_metadata_for_build_wheel(
5050
metadatadir, {}, _allow_fallback=False
5151
)
52+
53+
e = exc_info.value
54+
assert 'prepare_metadata_for_build_wheel' == e.hook_name
55+
assert 'prepare_metadata_for_build_wheel' in str(e)

0 commit comments

Comments
 (0)