Skip to content

Commit

Permalink
fix failing cnn and hashing tests due to use of pytest.warns(None) no…
Browse files Browse the repository at this point in the history
… longer working

reference: pytest-dev/pytest#9404
  • Loading branch information
Oliver Mangold committed Apr 23, 2024
1 parent 4e0b15f commit d0e6019
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/test_cnn.py
Expand Up @@ -8,6 +8,7 @@
import torch
from PIL import Image
import pytest
import warnings
from torchvision.transforms import transforms

from imagededup.methods.cnn import CNN
Expand Down Expand Up @@ -891,7 +892,8 @@ def test_find_duplicates_encoding_integration(cnn):
}

encodings = cnn.encode_images(TEST_IMAGE_DIR_MIXED)
with pytest.warns(None):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
duplicates = cnn.find_duplicates(
encoding_map=encodings, min_similarity_threshold=0.9, scores=True, outfile=False
)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_hashing.py
Expand Up @@ -5,6 +5,7 @@

from multiprocessing import cpu_count
import pytest
import warnings
import numpy as np

from imagededup.methods.hashing import Hashing, PHash, DHash, AHash, WHash
Expand Down Expand Up @@ -800,7 +801,8 @@ def test_find_duplicates_encoding_map_input():
'ukbench09268.jpg': 'c73c36c2da2f29c9',
}
phasher = PHash()
with pytest.warns(None):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
duplicate_dict = phasher.find_duplicates(
encoding_map=encoding, max_distance_threshold=10
)
Expand Down

0 comments on commit d0e6019

Please sign in to comment.