Commit f9bda3a5 by Chris Jerdonek

More Python 3 unit test fixes; README doctests also now working.

parent b042d084
# We keep all initialization code in a separate module.
from init import *
from pystache.init import *
......@@ -9,7 +9,7 @@ This module is only meant for internal use by the renderengine module.
import re
from parsed import ParsedTemplate
from pystache.parsed import ParsedTemplate
DEFAULT_DELIMITERS = ('{{', '}}')
......
......@@ -7,7 +7,7 @@ Defines a class responsible for rendering logic.
import re
from parser import Parser
from pystache.parser import Parser
class RenderEngine(object):
......
......@@ -15,7 +15,7 @@ from pystache.loader import Loader as Reader
from pystache.locator import Locator
from pystache.tests.common import DATA_DIR
from data.views import SayHello
from pystache.tests.data.views import SayHello
class LocatorTests(unittest.TestCase):
......
......@@ -14,6 +14,27 @@ from pystache.renderengine import RenderEngine
from pystache.tests.common import AssertStringMixin
def mock_literal(s):
"""
For use as the literal keyword argument to the RenderEngine constructor.
Arguments:
s: a byte string or unicode string.
"""
if isinstance(s, unicode):
# Strip off unicode super classes, if present.
u = unicode(s)
else:
u = unicode(s, encoding='ascii')
# We apply upper() to make sure we are actually using our custom
# function in the tests
return u.upper()
class RenderEngineTestCase(unittest.TestCase):
"""Test the RenderEngine class."""
......@@ -154,12 +175,9 @@ class RenderTests(unittest.TestCase, AssertStringMixin):
Test a context value that is not a basestring instance.
"""
# We use include upper() to make sure we are actually using
# our custom function in the tests
to_unicode = lambda s: unicode(s, encoding='ascii').upper()
engine = self._engine()
engine.escape = to_unicode
engine.literal = to_unicode
engine.escape = mock_literal
engine.literal = mock_literal
self.assertRaises(TypeError, engine.literal, 100)
......
......@@ -84,6 +84,7 @@ else:
# troubleshoot it while using Python 2.7 instead of Python 3.
extra = {
'use_2to3': True,
'convert_2to3_doctests': ['README.rst'],
}
setup(name='pystache',
......@@ -97,6 +98,9 @@ setup(name='pystache',
url='http://github.com/defunkt/pystache',
packages=find_packages(),
package_data = {
# Include the README so doctests can be run.
# TODO: is there a better way to include the README?
'pystache': ['../README.rst'],
# Include template files so tests can be run.
'examples': template_files,
'pystache.tests.data': template_files,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment