summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md3
-rw-r--r--pystache/__init__.py9
-rw-r--r--pystache/init.py4
-rw-r--r--pystache/tests/test___init__.py36
4 files changed, 42 insertions, 10 deletions
diff --git a/TODO.md b/TODO.md
index b6a57ef..3a8c8d9 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,4 +6,5 @@ TODO
* Provide support for logging in at least one of the commands.
* 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.
-* Combine pystache-test with the main command. \ No newline at end of file
+* Combine pystache-test with the main command.
+* Add a unittest that pystache.__version__ matches the version in setup.py.
diff --git a/pystache/__init__.py b/pystache/__init__.py
index eb3ee9f..f83739e 100644
--- a/pystache/__init__.py
+++ b/pystache/__init__.py
@@ -6,9 +6,8 @@ TODO: add a docstring.
# We keep all initialization code in a separate module.
# TODO: consider doing something like this instead:
-# from pystache.init import __version__, render, Renderer, TemplateSpec
-from pystache.init import *
+from pystache.init import render, Renderer, TemplateSpec
-# TODO: make sure that "from pystache import *" exposes only the following:
-# ['__version__', 'render', 'Renderer', 'TemplateSpec']
-# and add a unit test for this.
+__all__ = ['render', 'Renderer', 'TemplateSpec']
+
+__version__ = '0.5.1-alpha' # Also change in setup.py.
diff --git a/pystache/init.py b/pystache/init.py
index ba8b709..e9d854d 100644
--- a/pystache/init.py
+++ b/pystache/init.py
@@ -9,10 +9,6 @@ from pystache.renderer import Renderer
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):
"""
Return the given template string rendered using the given context.
diff --git a/pystache/tests/test___init__.py b/pystache/tests/test___init__.py
new file mode 100644
index 0000000..d4f3526
--- /dev/null
+++ b/pystache/tests/test___init__.py
@@ -0,0 +1,36 @@
+# 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)