def test_pngquant_should_optimize(self):
        optimizer = PngquantOptimizer(self.get_context())
        temp = tempfile.NamedTemporaryFile()
        optimizer.optimize(None, fixtures_folder + '/img/bend.png', temp.name)

        self.assertLessEqual(os.path.getsize(temp.name), os.path.getsize(fixtures_folder + '/img/bend.png'),
                             "pngquant could not lower filesize for img/bend.png")
Esempio n. 2
0
    def test_pngquant_should_optimize(self):
        optimizer = PngquantOptimizer(self.get_context())
        temp = tempfile.NamedTemporaryFile()
        optimizer.optimize(None, fixtures_folder + '/img/bend.png', temp.name)

        self.assertLessEqual(os.path.getsize(temp.name), os.path.getsize(fixtures_folder + '/img/bend.png'),
                             "pngquant could not lower filesize for img/bend.png")
    def test_pngquant_should_optimize(self):
        optimizer = PngquantOptimizer(self.get_context())
        with open(fixtures_folder + '/img/bend.png', 'rb') as f:
            buffer = f.read()
        return_buffer = optimizer.run_optimizer('.png', buffer)

        self.assertLessEqual(len(return_buffer), len(buffer),
                             "pngquant could not lower filesize for img/bend.png")
 def test_pngquant_should_run_for_png(self):
     optimizer = PngquantOptimizer(self.get_context())
     self.assertTrue(optimizer.should_run('png', None))
 def test_pngquant_should_not_run_for_jpeg(self):
     optimizer = PngquantOptimizer(self.get_context())
     self.assertFalse(optimizer.should_run('jpeg', None))
 def test_pngquant_should_run_for_png(self):
     optimizer = PngquantOptimizer(self.get_context())
     self.assertTrue(optimizer.should_run('png', None))
 def test_pngquant_should_not_run_for_jpeg(self):
     optimizer = PngquantOptimizer(self.get_context())
     self.assertFalse(optimizer.should_run('jpeg', None))