diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_corrupted_files.py | 7 | ||||
| -rw-r--r-- | tests/test_libmat2.py | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index 53c856a..b2cec00 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py | |||
| @@ -253,13 +253,13 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 253 | os.remove('./tests/data/clean.cleaned.html') | 253 | os.remove('./tests/data/clean.cleaned.html') |
| 254 | 254 | ||
| 255 | with open('./tests/data/clean.html', 'w') as f: | 255 | with open('./tests/data/clean.html', 'w') as f: |
| 256 | f.write('</close>') | 256 | f.write('</meta>') |
| 257 | with self.assertRaises(ValueError): | 257 | with self.assertRaises(ValueError): |
| 258 | web.HTMLParser('./tests/data/clean.html') | 258 | web.HTMLParser('./tests/data/clean.html') |
| 259 | os.remove('./tests/data/clean.html') | 259 | os.remove('./tests/data/clean.html') |
| 260 | 260 | ||
| 261 | with open('./tests/data/clean.html', 'w') as f: | 261 | with open('./tests/data/clean.html', 'w') as f: |
| 262 | f.write('<notclosed>') | 262 | f.write('<meta><a>test</a><set/></meta><title></title><meta>') |
| 263 | p = web.HTMLParser('./tests/data/clean.html') | 263 | p = web.HTMLParser('./tests/data/clean.html') |
| 264 | with self.assertRaises(ValueError): | 264 | with self.assertRaises(ValueError): |
| 265 | p.get_meta() | 265 | p.get_meta() |
| @@ -269,6 +269,9 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 269 | os.remove('./tests/data/clean.html') | 269 | os.remove('./tests/data/clean.html') |
| 270 | 270 | ||
| 271 | with open('./tests/data/clean.html', 'w') as f: | 271 | with open('./tests/data/clean.html', 'w') as f: |
| 272 | f.write('<meta><meta/></meta>') | ||
| 273 | f.write('<title><title>pouet</title></title>') | ||
| 274 | f.write('<title><mysupertag/></title>') | ||
| 272 | f.write('<doctitle><br/></doctitle><br/><notclosed>') | 275 | f.write('<doctitle><br/></doctitle><br/><notclosed>') |
| 273 | p = web.HTMLParser('./tests/data/clean.html') | 276 | p = web.HTMLParser('./tests/data/clean.html') |
| 274 | with self.assertRaises(ValueError): | 277 | with self.assertRaises(ValueError): |
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 249c56d..f4b1890 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | import unittest | 3 | import unittest |
| 4 | import shutil | 4 | import shutil |
| 5 | import os | 5 | import os |
| 6 | import re | ||
| 6 | import zipfile | 7 | import zipfile |
| 7 | 8 | ||
| 8 | from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless | 9 | from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless |
| @@ -644,7 +645,10 @@ class TestCleaning(unittest.TestCase): | |||
| 644 | self.assertTrue(ret) | 645 | self.assertTrue(ret) |
| 645 | 646 | ||
| 646 | p = epub.EPUBParser('./tests/data/clean.cleaned.epub') | 647 | p = epub.EPUBParser('./tests/data/clean.cleaned.epub') |
| 647 | self.assertEqual(p.get_meta(), {}) | 648 | meta = p.get_meta() |
| 649 | res = re.match(meta['OEBPS/content.opf']['metadata'], '^<dc:identifier>[0-9a-f-]+</dc:identifier><dc:title /><dc:language />$') | ||
| 650 | self.assertNotEqual(res, False) | ||
| 651 | |||
| 648 | self.assertTrue(p.remove_all()) | 652 | self.assertTrue(p.remove_all()) |
| 649 | 653 | ||
| 650 | os.remove('./tests/data/clean.epub') | 654 | os.remove('./tests/data/clean.epub') |
