1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-02-25 03:35:49 +01:00

Use the real constants module.

This is progressing refactor of the calibre code to make it more
readable, and transform it to something more coherent.

In this patch, there are changes regarding imports for some modules,
instead of polluting namespace of each module with some other modules
symbols, which often were imported from other modules. Yuck.
This commit is contained in:
2020-05-29 17:04:53 +02:00
parent ee4801228f
commit ce89f5c9d1
54 changed files with 2383 additions and 2081 deletions

View File

@@ -1,3 +1,7 @@
import os
import tempfile
import unittest
from lxml import etree
@@ -24,7 +28,6 @@ def safe_xml_fromstring(string_or_bytes, recover=True):
def find_tests():
import unittest, tempfile, os
class TestXMLParse(unittest.TestCase):
@@ -37,9 +40,11 @@ def find_tests():
os.remove(self.temp_file)
def test_safe_xml_fromstring(self):
templ = '''<!DOCTYPE foo [ <!ENTITY e {id} "{val}" > ]><r>&e;</r>'''
templ = '<!DOCTYPE foo [ <!ENTITY e {id} "{val}" > ]><r>&e;</r>'
external = 'file:///' + self.temp_file.replace(os.sep, '/')
self.assertEqual(etree.fromstring(templ.format(id='SYSTEM', val=external)).text, 'external')
self.assertEqual(etree.fromstring(templ.format(id='SYSTEM',
val=external)).text,
'external')
for eid, val, expected in (
('', 'normal entity', 'normal entity'),
('', external, external),
@@ -50,7 +55,8 @@ def find_tests():
('PUBLIC', external, None),
('PUBLIC', 'http://example.com', None),
):
got = getattr(safe_xml_fromstring(templ.format(id=eid, val=val)), 'text', None)
got = getattr(etree.fromstring(templ.format(id=eid, val=val)),
'text', None)
self.assertEqual(got, expected)
return unittest.defaultTestLoader.loadTestsFromTestCase(TestXMLParse)