8000 Fix image testing decorator in pytest importlib mode · matplotlib/matplotlib@c1b430b · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit c1b430b

Browse files
committed
Fix image testing decorator in pytest importlib mode
In importlib mode, files are not added to `sys.modules`, so we cannot use that to find the file path. Fixes #21885
1 parent 5bb1449 commit c1b430b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def _image_directories(func):
502502
``$(pwd)/result_images/test_baz``. The result directory is created if it
503503
doesn't exist.
504504
"""
505-
module_path = Path(sys.modules[func.__module__].__file__)
505+
module_path = Path(inspect.getfile(func))
506506
baseline_dir = module_path.parent / "baseline_images" / module_path.stem
507507
result_dir = Path().resolve() / "result_images" / module_path.stem
508508
result_dir.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)
0