diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_corrupted_files.py | 4 | ||||
| -rw-r--r-- | tests/test_libmat2.py | 27 |
2 files changed, 28 insertions, 3 deletions
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index b2cec00..4a16d51 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py | |||
| @@ -269,9 +269,6 @@ 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>') | ||
| 275 | f.write('<doctitle><br/></doctitle><br/><notclosed>') | 272 | f.write('<doctitle><br/></doctitle><br/><notclosed>') |
| 276 | p = web.HTMLParser('./tests/data/clean.html') | 273 | p = web.HTMLParser('./tests/data/clean.html') |
| 277 | with self.assertRaises(ValueError): | 274 | with self.assertRaises(ValueError): |
| @@ -281,6 +278,7 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 281 | p.remove_all() | 278 | p.remove_all() |
| 282 | os.remove('./tests/data/clean.html') | 279 | os.remove('./tests/data/clean.html') |
| 283 | 280 | ||
| 281 | |||
| 284 | def test_epub(self): | 282 | def test_epub(self): |
| 285 | with zipfile.ZipFile('./tests/data/clean.epub', 'w') as zout: | 283 | with zipfile.ZipFile('./tests/data/clean.epub', 'w') as zout: |
| 286 | zout.write('./tests/data/dirty.jpg', 'OEBPS/content.opf') | 284 | zout.write('./tests/data/dirty.jpg', 'OEBPS/content.opf') |
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index f4b1890..46e234e 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -633,6 +633,33 @@ class TestCleaning(unittest.TestCase): | |||
| 633 | os.remove('./tests/data/clean.cleaned.html') | 633 | os.remove('./tests/data/clean.cleaned.html') |
| 634 | os.remove('./tests/data/clean.cleaned.cleaned.html') | 634 | os.remove('./tests/data/clean.cleaned.cleaned.html') |
| 635 | 635 | ||
| 636 | with open('./tests/data/clean.html', 'w') as f: | ||
| 637 | f.write('<title><title><pouet/><meta/></title></title><test/>') | ||
| 638 | p = web.HTMLParser('./tests/data/clean.html') | ||
| 639 | self.assertTrue(p.remove_all()) | ||
| 640 | with open('./tests/data/clean.cleaned.html', 'r') as f: | ||
| 641 | self.assertEqual(f.read(), '<title></title><test/>') | ||
| 642 | os.remove('./tests/data/clean.html') | ||
| 643 | os.remove('./tests/data/clean.cleaned.html') | ||
| 644 | |||
| 645 | with open('./tests/data/clean.html', 'w') as f: | ||
| 646 | f.write('<test><title>Some<b>metadata</b><br/></title></test>') | ||
| 647 | p = web.HTMLParser('./tests/data/clean.html') | ||
| 648 | self.assertTrue(p.remove_all()) | ||
| 649 | with open('./tests/data/clean.cleaned.html', 'r') as f: | ||
| 650 | self.assertEqual(f.read(), '<test><title></title></test>') | ||
| 651 | os.remove('./tests/data/clean.html') | ||
| 652 | os.remove('./tests/data/clean.cleaned.html') | ||
| 653 | |||
| 654 | with open('./tests/data/clean.html', 'w') as f: | ||
| 655 | f.write('<meta><meta/></meta>') | ||
| 656 | p = web.HTMLParser('./tests/data/clean.html') | ||
| 657 | self.assertTrue(p.remove_all()) | ||
| 658 | with open('./tests/data/clean.cleaned.html', 'r') as f: | ||
| 659 | self.assertEqual(f.read(), '') | ||
| 660 | os.remove('./tests/data/clean.html') | ||
| 661 | os.remove('./tests/data/clean.cleaned.html') | ||
| 662 | |||
| 636 | 663 | ||
| 637 | def test_epub(self): | 664 | def test_epub(self): |
| 638 | shutil.copy('./tests/data/dirty.epub', './tests/data/clean.epub') | 665 | shutil.copy('./tests/data/dirty.epub', './tests/data/clean.epub') |
