def test_jpg(self): shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') p = images.JPGParser('./tests/data/clean.jpg') meta = p.get_meta() self.assertEqual(meta['Comment'], 'Created with GIMP') p.lightweight_cleaning = True ret = p.remove_all() self.assertTrue(ret) p = images.JPGParser('./tests/data/clean.cleaned.jpg') self.assertEqual(p.get_meta(), {}) os.remove('./tests/data/clean.jpg') os.remove('./tests/data/clean.cleaned.jpg')
def test_cleaning_multiple_one_fails(self): files = ['./tests/data/clean_%d.jpg' % i for i in range(9)] for f in files: shutil.copy('./tests/data/dirty.jpg', f) shutil.copy('./tests/data/dirty.torrent', './tests/data/clean_9.jpg') proc = subprocess.Popen(mat2_binary + ['--inplace'] + files, stdout=subprocess.PIPE) stdout, _ = proc.communicate() for f in files: p = images.JPGParser(f) meta = p.get_meta() self.assertEqual(meta, {}) for i in range(10): os.remove('./tests/data/clean_%d.jpg' % i)
def test_same(self): for i in range(self.iterations): shutil.copy('./tests/data/dirty.jpg', './tests/data/dirty_%d.jpg' % i) proc = subprocess.Popen( mat2_binary + ['./tests/data/dirty_%d.jpg' % i for i in range(self.iterations)], stdout=subprocess.PIPE) stdout, _ = proc.communicate() for i in range(self.iterations): path = './tests/data/dirty_%d.jpg' % i p = images.JPGParser('./tests/data/dirty_%d.cleaned.jpg' % i) self.assertEqual(p.get_meta(), {}) os.remove('./tests/data/dirty_%d.cleaned.jpg' % i) os.remove(path)
def test_faulty(self): for i in range(self.iterations): shutil.copy('./tests/data/dirty.jpg', './tests/data/dirty_%d.jpg' % i) shutil.copy('./tests/data/dirty.torrent', './tests/data/dirty_%d.docx' % i) to_process = [ './tests/data/dirty_%d.jpg' % i for i in range(self.iterations) ] to_process.extend( ['./tests/data/dirty_%d.docx' % i for i in range(self.iterations)]) random.shuffle(to_process) proc = subprocess.Popen(mat2_binary + to_process, stdout=subprocess.PIPE) stdout, _ = proc.communicate() for i in range(self.iterations): path = './tests/data/dirty_%d.jpg' % i p = images.JPGParser('./tests/data/dirty_%d.cleaned.jpg' % i) self.assertEqual(p.get_meta(), {}) os.remove('./tests/data/dirty_%d.cleaned.jpg' % i) os.remove(path) os.remove('./tests/data/dirty_%d.docx' % i)
def test_jpg(self): p = images.JPGParser('./tests/data/dirty.jpg') meta = p.get_meta() self.assertEqual(meta['Comment'], 'Created with GIMP')
def test_jpg(self): shutil.copy('./tests/data/dirty.mp3', './tests/data/clean.jpg') with self.assertRaises(ValueError): images.JPGParser('./tests/data/clean.jpg') os.remove('./tests/data/clean.jpg')