Skip to content

Commit

Permalink
Fix test_process_optimizes_image (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stormheg authored Sep 13, 2024
2 parents 976a923 + 010f960 commit f0a8471
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions tests/test_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ def setUpClass(cls) -> None:
cls.optimized_size = os.fstat(f.fileno()).st_size
cls.optimized_image = f.read()

def _fairly_equal(self, a, b, tolerance=0.001):
"""
Checks that two number are within a certain tolerance of each other.
We want to account for slight variations in how the libraries optimize the images under different OSes.
"""
return abs(a - b) <= tolerance * a

def test_process_optimizes_image(self):
try:
with NamedTemporaryFile(delete=False) as named_temporary_file:
Expand All @@ -90,10 +83,8 @@ def test_process_optimizes_image(self):
self.optimizer.process(image_file)

with open(image_file, "rb") as f:
self.assertTrue(
self._fairly_equal(
self.optimized_size, os.fstat(f.fileno()).st_size
)
self.assertAlmostEqual(
self.optimized_size, os.fstat(f.fileno()).st_size, delta=60
)
finally:
os.unlink(image_file)
Expand Down

0 comments on commit f0a8471

Please sign in to comment.