diff options
| author | jvoisin | 2019-02-27 23:53:07 +0100 |
|---|---|---|
| committer | jvoisin | 2019-02-27 23:53:07 +0100 |
| commit | 55214206b5f0f1c12fec378967f89ef4cb5674f9 (patch) | |
| tree | 82c94503dfd1d844b4c53d9083c69483d9d4f68d /tests/test_libmat2.py | |
| parent | 73d2966e8c10eb6c083a2abacc53f3297d16376e (diff) | |
Improve the previous commit
- More tests
- More documentation
- Minor code cleanup
Diffstat (limited to 'tests/test_libmat2.py')
| -rw-r--r-- | tests/test_libmat2.py | 27 |
1 files changed, 27 insertions, 0 deletions
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') |
