From bfc0d910d8243a536396eec4ed4ee5dc8e26a54b Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 13 Nov 2026 02:31:43 +0530 Subject: [PATCH] Show the requirement in the load() ValueError --- src/lazy_loader/__init__.py | 2 +- tests/test_lazy_loader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lazy_loader/__init__.py b/src/lazy_loader/__init__.py index 645b116..78bc3ee 100644 --- a/src/lazy_loader/__init__.py +++ b/src/lazy_loader/__init__.py @@ -269,7 +269,7 @@ def myfunc(): except ModuleNotFoundError as e: raise ValueError( f"Found module '{fullname}' but cannot test " - "requirement '{require}'. " + f"requirement '{require}'. " "Requirements must match distribution name, not module name." ) from e diff --git a/tests/test_lazy_loader.py b/tests/test_lazy_loader.py index b761fd2..8def656 100644 --- a/tests/test_lazy_loader.py +++ b/tests/test_lazy_loader.py @@ -261,7 +261,7 @@ def test_require_kwarg(): # When a module can be loaded but the version can't be checked, # raise a ValueError - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="requirement 'somepkg >= 1.0'"): lazy.load("math", require="somepkg >= 1.0")