imagededup
imagededup copied to clipboard
fix failing cnn and hashing tests due to use of pytest.warns(None)
Tests fail on Python 3.11:
tests/test_cnn.py:894:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = WarningsChecker(record=True), expected_warning = None, match_expr = None
def __init__(
self,
expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = Warning,
match_expr: Optional[Union[str, Pattern[str]]] = None,
*,
_ispytest: bool = False,
) -> None:
check_ispytest(_ispytest)
super().__init__(_ispytest=True)
msg = "exceptions must be derived from Warning, not %s"
if isinstance(expected_warning, tuple):
for exc in expected_warning:
if not issubclass(exc, Warning):
raise TypeError(msg % type(exc))
expected_warning_tup = expected_warning
elif isinstance(expected_warning, type) and issubclass(
expected_warning, Warning
):
expected_warning_tup = (expected_warning,)
else:
> raise TypeError(msg % type(expected_warning))
E TypeError: exceptions must be derived from Warning, not <class 'NoneType'>
/usr/lib/python3.11/site-packages/_pytest/recwarn.py:285: TypeError
The reason seems to be that with pytest.warns(None): is not a working method to check for that warnings are emitted with recent versions of pytest.
This fixes it for me.