Commit 78ca9df1 by Chris Jerdonek

Fixed spacing issues on partial test cases: trailing newline for standalones.

parent ca419315
## Again, {{title}}! ## ## Again, {{title}}! ##
\ No newline at end of file
...@@ -13,3 +13,17 @@ DATA_DIR = 'tests/data' ...@@ -13,3 +13,17 @@ DATA_DIR = 'tests/data'
def get_data_path(file_name): def get_data_path(file_name):
return os.path.join(DATA_DIR, file_name) return os.path.join(DATA_DIR, file_name)
def assert_strings(test_case, actual, expected):
# Show both friendly and literal versions.
message = """\
Expected: \"""%s\"""
Actual: \"""%s\"""
Expected: %s
Actual: %s""" % (expected, actual, repr(expected), repr(actual))
test_case.assertEquals(actual, expected, message)
...@@ -13,6 +13,9 @@ from examples.unicode_output import UnicodeOutput ...@@ -13,6 +13,9 @@ from examples.unicode_output import UnicodeOutput
from examples.unicode_input import UnicodeInput from examples.unicode_input import UnicodeInput
from examples.nested_context import NestedContext from examples.nested_context import NestedContext
from tests.common import assert_strings
class TestView(unittest.TestCase): class TestView(unittest.TestCase):
def test_comments(self): def test_comments(self):
self.assertEquals(Comments().render(), """<h1>A Comedy of Errors</h1> self.assertEquals(Comments().render(), """<h1>A Comedy of Errors</h1>
...@@ -47,13 +50,10 @@ Again, Welcome!""") ...@@ -47,13 +50,10 @@ Again, Welcome!""")
def test_template_partial_extension(self): def test_template_partial_extension(self):
view = TemplatePartial() view = TemplatePartial()
view.template_extension = 'txt' view.template_extension = 'txt'
self.assertEquals(view.render(), """Welcome assert_strings(self, view.render(), u"""Welcome
------- -------
## Again, Welcome! ## ## Again, Welcome! ##""")
""")
def test_delimiters(self): def test_delimiters(self):
self.assertEquals(Delimiters().render(), """ self.assertEquals(Delimiters().render(), """
......
import unittest import unittest
import pystache import pystache
from pystache import Renderer from pystache import Renderer
from examples.nested_context import NestedContext from examples.nested_context import NestedContext
...@@ -7,6 +8,9 @@ from examples.lambdas import Lambdas ...@@ -7,6 +8,9 @@ from examples.lambdas import Lambdas
from examples.template_partial import TemplatePartial from examples.template_partial import TemplatePartial
from examples.simple import Simple from examples.simple import Simple
from tests.common import assert_strings
class TestSimple(unittest.TestCase): class TestSimple(unittest.TestCase):
def test_nested_context(self): def test_nested_context(self):
...@@ -44,11 +48,19 @@ class TestSimple(unittest.TestCase): ...@@ -44,11 +48,19 @@ class TestSimple(unittest.TestCase):
def test_template_partial_extension(self): def test_template_partial_extension(self):
"""
Side note:
From the spec--
Partial tags SHOULD be treated as standalone when appropriate.
In particular, this means that trailing newlines should be removed.
"""
view = TemplatePartial() view = TemplatePartial()
view.template_extension = 'txt' view.template_extension = 'txt'
self.assertEquals(view.render(), """Welcome assert_strings(self, view.render(), u"""Welcome
------- -------
## Again, Welcome! ## ## Again, Welcome! ##""")
""")
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