Skip to content

Commit

Permalink
Merge pull request #640 from bmihelac/test/test-improvements
Browse files Browse the repository at this point in the history
Test/test improvements
  • Loading branch information
jrief authored Jul 29, 2024
2 parents d9d21ca + 0fea95a commit 68ed82d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions TESTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
your virtualenv setup, you can alternatively just ``pip install pytest-django testfixtures``
and run ``pytest``.
10 changes: 3 additions & 7 deletions easy_thumbnails/tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -214,15 +211,14 @@ 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 = {
'png': 'easy_thumbnails/tests/mockoptim.py {filename}'}
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(
Expand All @@ -240,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(
Expand Down

0 comments on commit 68ed82d

Please sign in to comment.