summaryrefslogtreecommitdiff
path: root/sandbox/docutils_xml/test/test_io.py
diff options
context:
space:
mode:
authorsmerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2013-12-07 10:43:41 +0000
committersmerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2013-12-07 10:43:41 +0000
commit4b95660019b8debaf6b5497bf4471fb4e22452b8 (patch)
treef9cd97bfe84124bc83312c9aff7b095897b8e9ee /sandbox/docutils_xml/test/test_io.py
parent05d0026ea1f52d4f4b0c4c3c42bd5aa32f9b9195 (diff)
downloaddocutils-4b95660019b8debaf6b5497bf4471fb4e22452b8.tar.gz
Added class `ZipFileInput`.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7738 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/docutils_xml/test/test_io.py')
-rw-r--r--sandbox/docutils_xml/test/test_io.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/sandbox/docutils_xml/test/test_io.py b/sandbox/docutils_xml/test/test_io.py
new file mode 100644
index 000000000..fb66314ed
--- /dev/null
+++ b/sandbox/docutils_xml/test/test_io.py
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2013 Stefan Merten
+
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; either version 2 of the License,
+# or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+"""
+Test I/O support classes for XML.
+"""
+
+import unittest
+
+import DocutilsTestSupport
+
+from docutils_xml.io import ZipFileInput
+
+###############################################################################
+
+class HelloZipFileInput(ZipFileInput):
+
+ content = u'Hello world!\n'
+
+ contentUnicode = u'Hello wörld!\n'
+
+ contentPath = "hello.txt"
+
+###############################################################################
+
+class InputTests(unittest.TestCase):
+
+ def test_simple(self):
+ input = HelloZipFileInput(source_path="data/hello.zip")
+ self.assertEqual(input.read(), HelloZipFileInput.content)
+
+ def test_nonZip(self):
+ input = HelloZipFileInput(source='')
+ with self.assertRaises(ValueError):
+ input.read()
+
+ def test_emptyZip(self):
+ input = HelloZipFileInput(source_path="data/empty.zip")
+ with self.assertRaises(KeyError):
+ input.read()
+
+ def test_undecodedZip(self):
+ input = HelloZipFileInput(source_path="data/utf8.zip")
+ self.assertEqual(input.read(),
+ HelloZipFileInput.contentUnicode.encode("utf-8"))
+
+ def test_utf8Zip(self):
+ input = HelloZipFileInput(source_path="data/utf8.zip", encoding="utf-8")
+ self.assertEqual(input.read(), HelloZipFileInput.contentUnicode)
+
+ def test_latin1Zip(self):
+ input = HelloZipFileInput(source_path="data/latin1.zip",
+ encoding="iso-8859-1")
+ self.assertEqual(input.read(), HelloZipFileInput.contentUnicode)