1. Christian Heimes
  2. defusedxml

Commits

Christian Heimes  committed 5a37f87

handle binary / text mode XML docs

  • Participants
  • Parent commits 4c2a37b
  • Branches default

Comments (0)

Files changed (1)

File tests.py

View file
 class BaseTests(unittest.TestCase):
     module = None
 
+    if PY3:
+        content_binary = False
+    else:
+        content_binary = True
+
+
     xml_dtd = os.path.join(HERE, "xmltestdata", "dtd.xml")
     xml_external = os.path.join(HERE, "xmltestdata", "external.xml")
     xml_quadratic = os.path.join(HERE, "xmltestdata", "quadratic.xml")
                 self.iterparse = self.module.iterparse
 
     def get_content(self, xmlfile):
-        if PY3:
-            mode = "r"
-        else:
-            mode = "rb"
+        mode = "rb" if self.content_binary else "r"
         with io.open(xmlfile, mode) as f:
-            return f.read()
+            data = f.read()
+        return data
 
     def test_simple_parse(self):
         self.parse(self.xml_simple)
 class TestDefusedSax(BaseTests):
     module = sax
 
+    content_binary = True
+
     iterparse = None
 
     def parse(self, xmlfile, **kwargs):