summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Bishop <stuart@stuartbishop.net>2014-03-21 06:12:11 +0000
committerStuart Bishop <stuart@stuartbishop.net>2014-03-21 06:12:11 +0000
commitb66c44499d38776f17b0be6acf8802e036512ec4 (patch)
tree5a9746d4bb207d129f8fde6ac9b1fab4a3017ed8
parent6d7de33f12264e88456b0c91c152c178aa25dbfe (diff)
downloadpytz-b66c44499d38776f17b0be6acf8802e036512ec4.tar.gz
Confirm README.txt is ASCII
-rw-r--r--src/pytz/tests/test_docs.py42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/pytz/tests/test_docs.py b/src/pytz/tests/test_docs.py
index 4302dca..fb49ec1 100644
--- a/src/pytz/tests/test_docs.py
+++ b/src/pytz/tests/test_docs.py
@@ -1,35 +1,33 @@
# -*- coding: ascii -*-
-from doctest import DocTestSuite
-import unittest, os, os.path, sys
-import warnings
-
-# We test the documentation this way instead of using DocFileSuite so
-# we can run the tests under Python 2.3
-def test_README():
- pass
-
-this_dir = os.path.dirname(__file__)
-locs = [
- os.path.join(this_dir, os.pardir, 'README.txt'),
- os.path.join(this_dir, os.pardir, os.pardir, 'README.txt'),
- ]
-for loc in locs:
- if os.path.exists(loc):
- test_README.__doc__ = open(loc).read()
- break
-if test_README.__doc__ is None:
- raise RuntimeError('README.txt not found')
+from doctest import DocFileSuite
+import unittest, os.path, sys
+
+THIS_DIR = os.path.dirname(__file__)
+
+README = os.path.join(THIS_DIR, os.pardir, os.pardir, 'README.txt')
+
+
+class DocumentationTestCase(unittest.TestCase):
+ def test_readme_encoding(self):
+ '''Confirm the README.txt is pure ASCII.'''
+ f = open(README, 'rb')
+ try:
+ f.read().decode('US-ASCII')
+ finally:
+ f.close()
def test_suite():
"For the Z3 test runner"
- return DocTestSuite()
+ return unittest.TestSuite((
+ DocumentationTestCase('test_readme_encoding'),
+ DocFileSuite(os.path.join(os.pardir, os.pardir, 'README.txt'))))
if __name__ == '__main__':
sys.path.insert(0, os.path.abspath(os.path.join(
- this_dir, os.pardir, os.pardir
+ THIS_DIR, os.pardir, os.pardir
)))
unittest.main(defaultTest='test_suite')