summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmat22
-rw-r--r--tests/test_climat2.py28
2 files changed, 30 insertions, 0 deletions
diff --git a/mat2 b/mat2
index e67fea0..01b834b 100755
--- a/mat2
+++ b/mat2
@@ -1,6 +1,7 @@
1#!/usr/bin/env python3 1#!/usr/bin/env python3
2 2
3import os 3import os
4import shutil
4from typing import Tuple, List, Union, Set 5from typing import Tuple, List, Union, Set
5import sys 6import sys
6import mimetypes 7import mimetypes
@@ -136,6 +137,7 @@ def clean_meta(filename: str, is_lightweight: bool, inplace: bool, sandbox: bool
136 try: 137 try:
137 logging.debug('Cleaning %s…', filename) 138 logging.debug('Cleaning %s…', filename)
138 ret = p.remove_all() 139 ret = p.remove_all()
140 shutil.copymode(filename, p.output_filename)
139 if inplace is True: 141 if inplace is True:
140 os.rename(p.output_filename, filename) 142 os.rename(p.output_filename, filename)
141 return ret 143 return ret
diff --git a/tests/test_climat2.py b/tests/test_climat2.py
index 9d816b1..17fce82 100644
--- a/tests/test_climat2.py
+++ b/tests/test_climat2.py
@@ -1,6 +1,7 @@
1import random 1import random
2import os 2import os
3import shutil 3import shutil
4import stat
4import subprocess 5import subprocess
5import unittest 6import unittest
6import glob 7import glob
@@ -132,6 +133,33 @@ class TestCleanMeta(unittest.TestCase):
132 self.assertNotIn(b'Comment: Created with GIMP', stdout) 133 self.assertNotIn(b'Comment: Created with GIMP', stdout)
133 134
134 os.remove('./tests/data/clean.jpg') 135 os.remove('./tests/data/clean.jpg')
136 os.remove('./tests/data/clean.cleaned.jpg')
137
138
139class TestCopyPermissions(unittest.TestCase):
140 def test_jpg_777(self):
141 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg')
142 os.chmod('./tests/data/clean.jpg', 0o777)
143
144 proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.jpg'],
145 stdout=subprocess.PIPE)
146 stdout, _ = proc.communicate()
147 self.assertIn(b'Comment: Created with GIMP', stdout)
148
149 proc = subprocess.Popen(mat2_binary + ['./tests/data/clean.jpg'],
150 stdout=subprocess.PIPE)
151 stdout, _ = proc.communicate()
152
153 proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.cleaned.jpg'],
154 stdout=subprocess.PIPE)
155 stdout, _ = proc.communicate()
156 self.assertNotIn(b'Comment: Created with GIMP', stdout)
157
158 permissions = os.stat('./tests/data/clean.cleaned.jpg')[stat.ST_MODE]
159 self.assertEqual(permissions, 0o100777)
160
161 os.remove('./tests/data/clean.jpg')
162 os.remove('./tests/data/clean.cleaned.jpg')
135 163
136 164
137class TestIsSupported(unittest.TestCase): 165class TestIsSupported(unittest.TestCase):