From 7e1f7a9d28efe8e0bdb6dfa0be355498c421a0a9 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 23 Aug 2023 15:51:19 +0200 Subject: [PATCH] Add spaces and non-UTF filenames to tests (#4517) --- tests/test_python.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/test_python.py b/tests/test_python.py index 0c4cc67607a..cefcd888af2 100644 --- a/tests/test_python.py +++ b/tests/test_python.py @@ -88,20 +88,25 @@ def test_predict_img(): def test_predict_grey_and_4ch(): # Convert SOURCE to greyscale and 4-ch im = Image.open(SOURCE) - source_greyscale = Path(f'{SOURCE.parent / SOURCE.stem}_greyscale.jpg') - source_rgba = Path(f'{SOURCE.parent / SOURCE.stem}_4ch.png') + stem = SOURCE.parent / SOURCE.stem + + source_greyscale = Path(f'{stem}_greyscale.jpg') + source_rgba = Path(f'{stem}_4ch.png') + source_non_utf = Path(f'{stem}_veĆ­culo.jpg') + source_spaces = Path(f'{stem} with spaces.jpg') + im.convert('L').save(source_greyscale) # greyscale im.convert('RGBA').save(source_rgba) # 4-ch PNG with alpha + im.save(source_non_utf) # non-UTF characters in filename + im.save(source_spaces) # spaces in filename # Inference model = YOLO(MODEL) - for f in source_rgba, source_greyscale: + for f in source_rgba, source_greyscale, source_non_utf, source_spaces: for source in Image.open(f), cv2.imread(str(f)), f: - model(source, save=True, verbose=True, imgsz=32) - - # Cleanup - source_greyscale.unlink() - source_rgba.unlink() + results = model(source, save=True, verbose=True, imgsz=32) + assert len(results) == 1 # verify that an image was run + f.unlink() # cleanup @pytest.mark.skipif(not ONLINE, reason='environment is offline')