Пример #1
0
 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))
Пример #2
0
 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))
Пример #3
0
 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))
Пример #4
0
 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))
Пример #5
0
 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))
Пример #6
0
 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))
Пример #7
0
 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))
Пример #8
0
 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))