Commit 3313e1f5 by Chris Jerdonek

Added unit tests for pystache/__init__.py.

parent ca91b7fc
...@@ -7,3 +7,4 @@ TODO ...@@ -7,3 +7,4 @@ TODO
* Make sure doctest text files can be converted for Python 3 when using tox. * Make sure doctest text files can be converted for Python 3 when using tox.
* Make sure command parsing to pystache-test doesn't break with Python 2.4 and earlier. * Make sure command parsing to pystache-test doesn't break with Python 2.4 and earlier.
* Combine pystache-test with the main command. * Combine pystache-test with the main command.
* Add a unittest that pystache.__version__ matches the version in setup.py.
...@@ -6,9 +6,8 @@ TODO: add a docstring. ...@@ -6,9 +6,8 @@ TODO: add a docstring.
# We keep all initialization code in a separate module. # We keep all initialization code in a separate module.
# TODO: consider doing something like this instead: # TODO: consider doing something like this instead:
# from pystache.init import __version__, render, Renderer, TemplateSpec from pystache.init import render, Renderer, TemplateSpec
from pystache.init import *
# TODO: make sure that "from pystache import *" exposes only the following: __all__ = ['render', 'Renderer', 'TemplateSpec']
# ['__version__', 'render', 'Renderer', 'TemplateSpec']
# and add a unit test for this. __version__ = '0.5.1-alpha' # Also change in setup.py.
...@@ -9,10 +9,6 @@ from pystache.renderer import Renderer ...@@ -9,10 +9,6 @@ from pystache.renderer import Renderer
from pystache.template_spec import TemplateSpec from pystache.template_spec import TemplateSpec
__all__ = ['__version__', 'render', 'Renderer', 'TemplateSpec']
__version__ = '0.5.1-alpha' # Also change in setup.py.
def render(template, context=None, **kwargs): def render(template, context=None, **kwargs):
""" """
Return the given template string rendered using the given context. Return the given template string rendered using the given context.
......
# coding: utf-8
"""
Tests of __init__.py.
"""
# Calling "import *" is allowed only at the module level.
GLOBALS_INITIAL = globals().keys()
from pystache import *
GLOBALS_PYSTACHE_IMPORTED = globals().keys()
import unittest
import pystache
class InitTests(unittest.TestCase):
def test___all__(self):
"""
Test that "from pystache import *" works as expected.
"""
actual = set(GLOBALS_PYSTACHE_IMPORTED) - set(GLOBALS_INITIAL)
expected = set(['render', 'Renderer', 'TemplateSpec', 'GLOBALS_INITIAL'])
self.assertEqual(actual, expected)
def test_version_defined(self):
"""
Test that pystache.__version__ is set.
"""
actual_version = pystache.__version__
self.assertTrue(actual_version)
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