Beispiel #1
0
    def test_exiftool_overwrite(self):
        target = './tests/data/clean.png'
        shutil.copy('./tests/data/dirty.png', target)

        p1 = images.PNGParser(target)
        p1.lightweight_cleaning = True
        shutil.copy('./tests/data/dirty.png', p1.output_filename)
        self.assertTrue(p1.remove_all())

        p2 = images.PNGParser(p1.output_filename)
        self.assertEqual(p2.get_meta(), {})

        os.remove(target)
        os.remove(p1.output_filename)
Beispiel #2
0
 def test_ver_injection(self):
     shutil.copy('./tests/data/dirty.png', './-ver')
     p = images.PNGParser('-ver')
     meta = p.get_meta()
     self.assertEqual(meta['Comment'], 'This is a comment, be careful!')
     self.assertEqual(meta['ModifyDate'], "2018:03:20 21:59:25")
     os.remove('-ver')
Beispiel #3
0
    def test_png(self):
        shutil.copy('./tests/data/dirty.png', './tests/data/clean.png')
        p = images.PNGParser('./tests/data/clean.png')

        meta = p.get_meta()
        self.assertEqual(meta['Comment'], 'This is a comment, be careful!')

        ret = p.remove_all()
        self.assertTrue(ret)

        p = images.PNGParser('./tests/data/clean.cleaned.png')
        self.assertEqual(p.get_meta(), {})
        self.assertTrue(p.remove_all())

        os.remove('./tests/data/clean.png')
        os.remove('./tests/data/clean.cleaned.png')
        os.remove('./tests/data/clean.cleaned.cleaned.png')
Beispiel #4
0
 def test_png(self):
     p = images.PNGParser('./tests/data/dirty.png')
     meta = p.get_meta()
     self.assertEqual(meta['Comment'], 'This is a comment, be careful!')
     self.assertEqual(meta['ModifyDate'], "2018:03:20 21:59:25")
Beispiel #5
0
 def test_png_lightweight(self):
     return
     shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.png')
     p = images.PNGParser('./tests/data/clean.png')
     self.assertTrue(p.remove_all())
     os.remove('./tests/data/clean.png')
Beispiel #6
0
 def test_png(self):
     shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf')
     with self.assertRaises(ValueError):
         images.PNGParser('./tests/data/clean.pdf')
     os.remove('./tests/data/clean.pdf')
Beispiel #7
0
 def test_png_lightweight(self):
     shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.png')
     with self.assertRaises(ValueError):
         images.PNGParser('./tests/data/clean.png')
     os.remove('./tests/data/clean.png')