From 73d2966e8c10eb6c083a2abacc53f3297d16376e Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 27 Feb 2019 23:04:38 +0100 Subject: Improve epub support --- tests/test_corrupted_files.py | 7 +++++-- tests/test_libmat2.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'tests') 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): os.remove('./tests/data/clean.cleaned.html') with open('./tests/data/clean.html', 'w') as f: - f.write('') + f.write('') with self.assertRaises(ValueError): web.HTMLParser('./tests/data/clean.html') os.remove('./tests/data/clean.html') with open('./tests/data/clean.html', 'w') as f: - f.write('') + f.write('test') p = web.HTMLParser('./tests/data/clean.html') with self.assertRaises(ValueError): p.get_meta() @@ -269,6 +269,9 @@ class TestCorruptedFiles(unittest.TestCase): os.remove('./tests/data/clean.html') with open('./tests/data/clean.html', 'w') as f: + f.write('') + f.write('<title>pouet') + f.write('<mysupertag/>') f.write('

') p = web.HTMLParser('./tests/data/clean.html') 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 @@ import unittest import shutil import os +import re import zipfile from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless @@ -644,7 +645,10 @@ class TestCleaning(unittest.TestCase): self.assertTrue(ret) p = epub.EPUBParser('./tests/data/clean.cleaned.epub') - self.assertEqual(p.get_meta(), {}) + meta = p.get_meta() + res = re.match(meta['OEBPS/content.opf']['metadata'], '^[0-9a-f-]+$') + self.assertNotEqual(res, False) + self.assertTrue(p.remove_all()) os.remove('./tests/data/clean.epub') -- cgit v1.3