def test_pass_rw_object_withou_o(self): self.png1_f.seek(0, os.SEEK_END) original_size = self.png1_f.tell() self.assertTrue(optimize_png_file(self.png1_f)) self.assertImageFormat(self.png1_f, 'PNG') self.png1_f.seek(0, os.SEEK_END) self.assertTrue(original_size > (self.png1_f.tell() * 0.2))
def test_pass_path_to_files(self): o_fn = os.path.join(settings.TMP_DIR, 'test1_result.png') self.assertTrue(optimize_png_file(self.png1_fn, o_fn)) self.assertTrue(os.path.exists(o_fn)) self.assertImageFormat(open(o_fn, 'rb'), 'PNG') self.assertTrue( os.path.getsize(self.png1_fn) > (os.path.getsize(o_fn) * 0.2))
def test_pass_rw_object(self): o = cStringIO.StringIO() self.assertTrue(optimize_png_file(self.png1_f, o)) self.assertImageFormat(o, 'PNG') self.png1_f.seek(0, os.SEEK_END) o.seek(0, os.SEEK_END) self.assertTrue(self.png1_f.tell() > (o.tell() * 0.2))
def test_pass_rw_object_withou_o(self): self.png1_f.seek(0, os.SEEK_END) original_size = self.png1_f.tell() self.assertTrue(optimize_png_file(self.png1_f)) self.assertImageFormat(self.png1_f, "PNG") self.png1_f.seek(0, os.SEEK_END) self.assertTrue(original_size > (self.png1_f.tell() * 0.2))
def test_pass_rw_object(self): o = cStringIO.StringIO() self.assertTrue(optimize_png_file(self.png1_f, o)) self.assertImageFormat(o, "PNG") self.png1_f.seek(0, os.SEEK_END) o.seek(0, os.SEEK_END) self.assertTrue(self.png1_f.tell() > (o.tell() * 0.2))
def test_pass_path_to_files_without_o(self): original_size = os.path.getsize(self.png1_fn) self.assertTrue(optimize_png_file(self.png1_fn)) self.assertTrue(os.path.exists(self.png1_fn)) self.assertImageFormat(open(self.png1_fn, 'rb'), 'PNG') self.assertTrue(original_size > (os.path.getsize(self.png1_fn) * 0.2))
def test_pass_path_to_files_without_o(self): original_size = os.path.getsize(self.png1_fn) self.assertTrue(optimize_png_file(self.png1_fn)) self.assertTrue(os.path.exists(self.png1_fn)) self.assertImageFormat(open(self.png1_fn, "rb"), "PNG") self.assertTrue(original_size > (os.path.getsize(self.png1_fn) * 0.2))
def test_pass_path_to_files(self): o_fn = os.path.join(settings.TMP_DIR, "test1_result.png") self.assertTrue(optimize_png_file(self.png1_fn, o_fn)) self.assertTrue(os.path.exists(o_fn)) self.assertImageFormat(open(o_fn, "rb"), "PNG") self.assertTrue(os.path.getsize(self.png1_fn) > (os.path.getsize(o_fn) * 0.2))