From 561ae026b664a85bc4451f526b1b15e9e5cc2c35 Mon Sep 17 00:00:00 2001 From: Bojan Mihelac Date: Mon, 29 Jul 2024 10:33:11 +0200 Subject: [PATCH 1/2] Do not skip tests when testfixtures is missing (#639) --- TESTING.rst | 4 ++-- easy_thumbnails/tests/test_files.py | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/TESTING.rst b/TESTING.rst index cd7fe99a..6ff7b7b0 100644 --- a/TESTING.rst +++ b/TESTING.rst @@ -14,5 +14,5 @@ pytest ------ Assuming you're just wanting to test the current development version against -your virtualenv setup, you can alternatively just ``pip install pytest-django`` -and run ``pytest``. \ No newline at end of file +your virtualenv setup, you can alternatively just ``pip install pytest-django testfixtures`` +and run ``pytest``. diff --git a/easy_thumbnails/tests/test_files.py b/easy_thumbnails/tests/test_files.py index 9b8f0381..ee9c901c 100644 --- a/easy_thumbnails/tests/test_files.py +++ b/easy_thumbnails/tests/test_files.py @@ -7,10 +7,7 @@ from easy_thumbnails.options import ThumbnailOptions from easy_thumbnails.tests import utils as test from PIL import Image -try: - from testfixtures import LogCapture -except ImportError: - LogCapture = None +from testfixtures import LogCapture import unittest From 0fea95a6f4fd8719725083b3b00c17bfd0cc9458 Mon Sep 17 00:00:00 2001 From: Bojan Mihelac Date: Mon, 29 Jul 2024 10:37:30 +0200 Subject: [PATCH 2/2] Check last log message instead of first one in FilesTest tests --- easy_thumbnails/tests/test_files.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/easy_thumbnails/tests/test_files.py b/easy_thumbnails/tests/test_files.py index ee9c901c..b88a8ae7 100644 --- a/easy_thumbnails/tests/test_files.py +++ b/easy_thumbnails/tests/test_files.py @@ -211,7 +211,6 @@ def test_default_subsampling(self): @unittest.skipIf( 'easy_thumbnails.optimize' not in settings.INSTALLED_APPS, 'optimize app not installed') - @unittest.skipIf(LogCapture is None, 'testfixtures not installed') def test_postprocessor(self): """use a mock image optimizing post processor doing nothing""" settings.THUMBNAIL_OPTIMIZE_COMMAND = { @@ -219,7 +218,7 @@ def test_postprocessor(self): with LogCapture() as logcap: self.ext_thumbnailer.thumbnail_extension = 'png' self.ext_thumbnailer.get_thumbnail({'size': (10, 10)}) - actual = tuple(logcap.actual())[0] + actual = tuple(logcap.actual())[-1] self.assertEqual(actual[0], 'easy_thumbnails.optimize') self.assertEqual(actual[1], 'INFO') self.assertRegex( @@ -237,7 +236,7 @@ def test_postprocessor_fail(self): with LogCapture() as logcap: self.ext_thumbnailer.thumbnail_extension = 'png' self.ext_thumbnailer.get_thumbnail({'size': (10, 10)}) - actual = tuple(logcap.actual())[0] + actual = tuple(logcap.actual())[-1] self.assertEqual(actual[0], 'easy_thumbnails.optimize') self.assertEqual(actual[1], 'ERROR') self.assertRegex(