diff options
| author | jvoisin | 2018-09-24 19:50:24 +0200 |
|---|---|---|
| committer | jvoisin | 2018-09-24 19:50:24 +0200 |
| commit | 2e243355f51654c8c6392c80a17b090f9f012fd1 (patch) | |
| tree | b4bb244443ab0566cdb741b1c91a112ff8149214 | |
| parent | 174d4a0ac09c2e9d4a9aa3677a442c05459b8309 (diff) | |
Fix some minor formatting issues
| -rw-r--r-- | libmat2/archive.py | 2 | ||||
| -rw-r--r-- | libmat2/office.py | 2 | ||||
| -rw-r--r-- | libmat2/pdf.py | 2 | ||||
| -rw-r--r-- | tests/test_climat2.py | 1 | ||||
| -rw-r--r-- | tests/test_corrupted_files.py | 16 | ||||
| -rw-r--r-- | tests/test_deep_cleaning.py | 2 | ||||
| -rw-r--r-- | tests/test_libmat2.py | 2 | ||||
| -rw-r--r-- | tests/test_policy.py | 1 |
8 files changed, 15 insertions, 13 deletions
diff --git a/libmat2/archive.py b/libmat2/archive.py index 7b9f335..dd63c50 100644 --- a/libmat2/archive.py +++ b/libmat2/archive.py | |||
| @@ -21,7 +21,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): | |||
| 21 | 21 | ||
| 22 | # Those are the files that we _do not_ want to keep, | 22 | # Those are the files that we _do not_ want to keep, |
| 23 | # no matter if they are supported or not. | 23 | # no matter if they are supported or not. |
| 24 | files_to_omit = set() # type: Set[Pattern] | 24 | files_to_omit = set() # type: Set[Pattern] |
| 25 | 25 | ||
| 26 | # what should the parser do if it encounters an unknown file in | 26 | # what should the parser do if it encounters an unknown file in |
| 27 | # the archive? | 27 | # the archive? |
diff --git a/libmat2/office.py b/libmat2/office.py index 07bbbb9..c6b324b 100644 --- a/libmat2/office.py +++ b/libmat2/office.py | |||
| @@ -21,7 +21,7 @@ def _parse_xml(full_path: str): | |||
| 21 | for _, (key, value) in ET.iterparse(full_path, ("start-ns", )): | 21 | for _, (key, value) in ET.iterparse(full_path, ("start-ns", )): |
| 22 | # The ns[0-9]+ namespaces are reserved for interal usage, so | 22 | # The ns[0-9]+ namespaces are reserved for interal usage, so |
| 23 | # we have to use an other nomenclature. | 23 | # we have to use an other nomenclature. |
| 24 | if re.match('^ns[0-9]+$', key, re.I): #pragma: no cover | 24 | if re.match('^ns[0-9]+$', key, re.I): # pragma: no cover |
| 25 | key = 'mat' + key[2:] | 25 | key = 'mat' + key[2:] |
| 26 | 26 | ||
| 27 | namespace_map[key] = value | 27 | namespace_map[key] = value |
diff --git a/libmat2/pdf.py b/libmat2/pdf.py index bc7c8a6..5e19ef7 100644 --- a/libmat2/pdf.py +++ b/libmat2/pdf.py | |||
| @@ -17,7 +17,7 @@ from gi.repository import Poppler, GLib | |||
| 17 | from . import abstract | 17 | from . import abstract |
| 18 | 18 | ||
| 19 | poppler_version = Poppler.get_version() | 19 | poppler_version = Poppler.get_version() |
| 20 | if LooseVersion(poppler_version) < LooseVersion('0.46'): # pragma: no cover | 20 | if LooseVersion(poppler_version) < LooseVersion('0.46'): # pragma: no cover |
| 21 | raise ValueError("MAT2 needs at least Poppler version 0.46 to work. \ | 21 | raise ValueError("MAT2 needs at least Poppler version 0.46 to work. \ |
| 22 | The installed version is %s." % poppler_version) # pragma: no cover | 22 | The installed version is %s." % poppler_version) # pragma: no cover |
| 23 | 23 | ||
diff --git a/tests/test_climat2.py b/tests/test_climat2.py index a94fc23..b84afdf 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py | |||
| @@ -77,7 +77,6 @@ class TestCleanFolder(unittest.TestCase): | |||
| 77 | shutil.rmtree('./tests/data/folder/') | 77 | shutil.rmtree('./tests/data/folder/') |
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | |||
| 81 | class TestCleanMeta(unittest.TestCase): | 80 | class TestCleanMeta(unittest.TestCase): |
| 82 | def test_jpg(self): | 81 | def test_jpg(self): |
| 83 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') | 82 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') |
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index 72d124f..aee1530 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py | |||
| @@ -53,16 +53,21 @@ class TestUnsupportedFiles(unittest.TestCase): | |||
| 53 | class TestCorruptedEmbedded(unittest.TestCase): | 53 | class TestCorruptedEmbedded(unittest.TestCase): |
| 54 | def test_docx(self): | 54 | def test_docx(self): |
| 55 | shutil.copy('./tests/data/embedded_corrupted.docx', './tests/data/clean.docx') | 55 | shutil.copy('./tests/data/embedded_corrupted.docx', './tests/data/clean.docx') |
| 56 | parser, mimetype = parser_factory.get_parser('./tests/data/clean.docx') | 56 | parser, _ = parser_factory.get_parser('./tests/data/clean.docx') |
| 57 | self.assertFalse(parser.remove_all()) | 57 | self.assertFalse(parser.remove_all()) |
| 58 | self.assertIsNotNone(parser.get_meta()) | 58 | self.assertIsNotNone(parser.get_meta()) |
| 59 | os.remove('./tests/data/clean.docx') | 59 | os.remove('./tests/data/clean.docx') |
| 60 | 60 | ||
| 61 | def test_odt(self): | 61 | def test_odt(self): |
| 62 | expected = { | ||
| 63 | 'create_system': 'Weird', | ||
| 64 | 'date_time': '2018-06-10 17:18:18', | ||
| 65 | 'meta.xml': 'harmful content' | ||
| 66 | } | ||
| 62 | shutil.copy('./tests/data/embedded_corrupted.odt', './tests/data/clean.odt') | 67 | shutil.copy('./tests/data/embedded_corrupted.odt', './tests/data/clean.odt') |
| 63 | parser, mimetype = parser_factory.get_parser('./tests/data/clean.odt') | 68 | parser, _ = parser_factory.get_parser('./tests/data/clean.odt') |
| 64 | self.assertFalse(parser.remove_all()) | 69 | self.assertFalse(parser.remove_all()) |
| 65 | self.assertEqual(parser.get_meta(), {'create_system': 'Weird', 'date_time': '2018-06-10 17:18:18', 'meta.xml': 'harmful content'}) | 70 | self.assertEqual(parser.get_meta(), expected) |
| 66 | os.remove('./tests/data/clean.odt') | 71 | os.remove('./tests/data/clean.odt') |
| 67 | 72 | ||
| 68 | 73 | ||
| @@ -90,7 +95,7 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 90 | 95 | ||
| 91 | def test_png2(self): | 96 | def test_png2(self): |
| 92 | shutil.copy('./tests/test_libmat2.py', './tests/clean.png') | 97 | shutil.copy('./tests/test_libmat2.py', './tests/clean.png') |
| 93 | parser, mimetype = parser_factory.get_parser('./tests/clean.png') | 98 | parser, _ = parser_factory.get_parser('./tests/clean.png') |
| 94 | self.assertIsNone(parser) | 99 | self.assertIsNone(parser) |
| 95 | os.remove('./tests/clean.png') | 100 | os.remove('./tests/clean.png') |
| 96 | 101 | ||
| @@ -134,7 +139,8 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 134 | 139 | ||
| 135 | def test_bmp(self): | 140 | def test_bmp(self): |
| 136 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.bmp') | 141 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.bmp') |
| 137 | harmless.HarmlessParser('./tests/data/clean.bmp') | 142 | ret = harmless.HarmlessParser('./tests/data/clean.bmp') |
| 143 | self.assertIsNotNone(ret) | ||
| 138 | os.remove('./tests/data/clean.bmp') | 144 | os.remove('./tests/data/clean.bmp') |
| 139 | 145 | ||
| 140 | def test_docx(self): | 146 | def test_docx(self): |
diff --git a/tests/test_deep_cleaning.py b/tests/test_deep_cleaning.py index 82579a3..4f1920d 100644 --- a/tests/test_deep_cleaning.py +++ b/tests/test_deep_cleaning.py | |||
| @@ -23,7 +23,6 @@ class TestZipMetadata(unittest.TestCase): | |||
| 23 | self.assertEqual(inside_p.get_meta(), {}) | 23 | self.assertEqual(inside_p.get_meta(), {}) |
| 24 | shutil.rmtree(tempdir) | 24 | shutil.rmtree(tempdir) |
| 25 | 25 | ||
| 26 | |||
| 27 | def __check_zip_meta(self, p): | 26 | def __check_zip_meta(self, p): |
| 28 | zipin = zipfile.ZipFile(p.filename) | 27 | zipin = zipfile.ZipFile(p.filename) |
| 29 | for item in zipin.infolist(): | 28 | for item in zipin.infolist(): |
| @@ -135,4 +134,3 @@ class TestRsidRemoval(unittest.TestCase): | |||
| 135 | 134 | ||
| 136 | os.remove('./tests/data/clean.docx') | 135 | os.remove('./tests/data/clean.docx') |
| 137 | os.remove('./tests/data/clean.cleaned.docx') | 136 | os.remove('./tests/data/clean.cleaned.docx') |
| 138 | |||
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index d8c7b83..7a1a9e7 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -12,7 +12,7 @@ from libmat2 import check_dependencies | |||
| 12 | class TestCheckDependencies(unittest.TestCase): | 12 | class TestCheckDependencies(unittest.TestCase): |
| 13 | def test_deps(self): | 13 | def test_deps(self): |
| 14 | ret = check_dependencies() | 14 | ret = check_dependencies() |
| 15 | for key, value in ret.items(): | 15 | for value in ret.values(): |
| 16 | self.assertTrue(value) | 16 | self.assertTrue(value) |
| 17 | 17 | ||
| 18 | 18 | ||
diff --git a/tests/test_policy.py b/tests/test_policy.py index 890f8c3..ef55644 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py | |||
| @@ -29,4 +29,3 @@ class TestPolicy(unittest.TestCase): | |||
| 29 | with self.assertRaises(ValueError): | 29 | with self.assertRaises(ValueError): |
| 30 | p.unknown_member_policy = UnknownMemberPolicy('unknown_policy_name_totally_invalid') | 30 | p.unknown_member_policy = UnknownMemberPolicy('unknown_policy_name_totally_invalid') |
| 31 | os.remove('./tests/data/clean.docx') | 31 | os.remove('./tests/data/clean.docx') |
| 32 | |||
