summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-04-10 22:31:28 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-04-10 22:31:28 -0700
commit84e24e5e8451d1845129c4e9d7c3fcf10995ca08 (patch)
tree8aef5456af069c5e40b32cc8e9c024e6e3446b93
parent9d1e3aad107b37794d383ff37fa3590c6f1bc45c (diff)
downloadpystache-84e24e5e8451d1845129c4e9d7c3fcf10995ca08.tar.gz
Tests now pass with Python 3.1.
-rw-r--r--README.rst2
-rw-r--r--pystache/defaults.py7
-rw-r--r--pystache/tests/test_renderer.py4
3 files changed, 10 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index 23acc61..dd7d685 100644
--- a/README.rst
+++ b/README.rst
@@ -204,7 +204,7 @@ Author
.. _Mustache: http://mustache.github.com/
.. _Mustache spec: https://github.com/mustache/spec
.. _mustache(5): http://mustache.github.com/mustache.5.html
-.. _nose: http://somethingaboutorange.com/mrl/projects/nose/0.11.1/testing.html
+.. _nose: http://readthedocs.org/docs/nose/en/latest/
.. _only unicode strings: http://docs.python.org/howto/unicode.html#tips-for-writing-unicode-aware-programs
.. _PyPI: http://pypi.python.org/pypi/pystache
.. _Pystache: https://github.com/defunkt/pystache
diff --git a/pystache/defaults.py b/pystache/defaults.py
index bb989c5..e12e635 100644
--- a/pystache/defaults.py
+++ b/pystache/defaults.py
@@ -11,6 +11,13 @@ does not otherwise specify a value.
try:
# Python 3.2 deprecates cgi.escape() and adds the html module as a replacement.
import html
+ try:
+ # We also need to verify the existence of the escape() method
+ # due to the following issue:
+ # http://bugs.python.org/issue14545
+ html.escape
+ except AttributeError:
+ raise ImportError("html.escape does not exist")
except ImportError:
import cgi as html
diff --git a/pystache/tests/test_renderer.py b/pystache/tests/test_renderer.py
index c022079..64a4325 100644
--- a/pystache/tests/test_renderer.py
+++ b/pystache/tests/test_renderer.py
@@ -63,8 +63,8 @@ class RendererInitTestCase(unittest.TestCase):
self.assertEqual(escape(">"), "&gt;")
self.assertEqual(escape('"'), "&quot;")
- # Single quotes are escaped in Python 3 but not Python 2.
- if sys.version_info < (3, ):
+ # Single quotes are escaped only in Python 3.2 and later.
+ if sys.version_info < (3, 2):
expected = "'"
else:
expected = '&#x27;'