@@ -351,8 +351,12 @@ def __init__(self,
351
351
emsg = f'Unrecognised hashing kernel { kernel !r} not supported.'
352
352
raise ValueError (emsg )
353
353
kernel = requested
354
+ # Flag that the kernel has been user configured.
355
+ self .kernel_default = False
354
356
else :
355
357
kernel = DEFAULT_KERNEL
358
+ # Flag that the kernel has been configured by default.
359
+ self .kernel_default = True
356
360
# Create the kernel.
357
361
self .kernel = kernel_factory [kernel ](self )
358
362
@@ -631,12 +635,15 @@ def compare_image_to_hash_library(self, item, fig, result_dir, summary=None):
631
635
f'in the hash library { str (hash_library_filename )!r} .' )
632
636
pytest .fail (emsg )
633
637
if kernel_name != self .kernel .name :
634
- # TODO: we could be lenient here by raising a warning and hot-swap to
635
- # use the hash library kernel, instead of forcing a test failure?
636
- emsg = (f'Hash library { str (hash_library_filename )!r} kernel '
637
- f'{ kernel_name !r} does not match configured runtime '
638
- f'kernel { self .kernel .name !r} .' )
639
- pytest .fail (emsg )
638
+ if self .kernel_default :
639
+ # Override the default kernel with the kernel configured
640
+ # within the hash library.
641
+ self .kernel = kernel_factory [kernel_name ](self )
642
+ else :
643
+ emsg = (f'Hash library { str (hash_library_filename )!r} kernel '
644
+ f'{ kernel_name !r} does not match configured runtime '
645
+ f'kernel { self .kernel .name !r} .' )
646
+ pytest .fail (emsg )
640
647
641
648
hash_name = self .generate_test_name (item )
642
649
baseline_hash = hash_library .get (hash_name , None )
0 commit comments