Пример #1
0
    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')
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
 def test_jpg(self):
     p = images.JPGParser('./tests/data/dirty.jpg')
     meta = p.get_meta()
     self.assertEqual(meta['Comment'], 'Created with GIMP')
Пример #6
0
 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')