Commit f30aad9a by Chris Jerdonek

Changes in preparation for 0.5.1.

parent e05966ee
......@@ -25,19 +25,20 @@ Requirements
Pystache is tested with the following versions of Python:
* Python 2.4 (requires simplejson version 2.0.9 or earlier)
* Python 2.5 (requires simplejson)
* Python 2.4 (requires `simplejson version 2.0.9`_ or earlier)
* Python 2.5 (requires simplejson_)
* Python 2.6
* Python 2.7
* Python 3.1
* Python 3.2
JSON support is needed only for the command-line interface and to run the
spec tests. We require simplejson_ for earlier versions of Python since
Python's json_ module was added in Python 2.6. Moreover, we require an
earlier version of simplejson for Python 2.4 since simplejson stopped
officially supporting Python 2.4 with version 2.1.0.
spec tests. We require simplejson for earlier versions of Python since
Python's json_ module was added in Python 2.6.
An earlier version of simplejson can be installed manually, as follows: ::
For Python 2.4 we require an earlier version of simplejson since simplejson
stopped officially supporting Python 2.4 in simplejson version 2.1.0.
Earlier versions of simplejson can be installed manually, as follows: ::
pip install 'simplejson<2.1.0'
......@@ -162,9 +163,11 @@ Mustache spec. To include tests from the Mustache spec in your test runs: ::
git submodule init
git submodule update
The test harness parses the spec's yaml files if PyYAML_ is present.
Otherwise, it parses the json files.
To test Pystache from a source distribution with Python 3.x, you must use tox.
This is because the raw source is not Python 3 compatible and must first be
run through 2to3_.
This is because the source code must first be run through 2to3_.
Mailing List
......@@ -183,9 +186,9 @@ Author
::
>>> context = { 'author': 'Chris Wanstrath', 'email': 'chris@ozmm.org' }
>>> print pystache.render("{{author}} :: {{email}}", context)
Chris Wanstrath :: chris@ozmm.org
>>> context = { 'author': 'Chris Wanstrath', 'maintainer': 'Chris Jerdonek' }
>>> print pystache.render("{{author}} :: {{maintainer}}", context)
Chris Wanstrath :: Chris Jerdonek
.. _2to3: http://docs.python.org/library/2to3.html
......@@ -202,8 +205,10 @@ Author
.. _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
.. _PyYAML: http://pypi.python.org/pypi/PyYAML
.. _semantically versioned: http://semver.org
.. _simplejson: http://pypi.python.org/pypi/simplejson/
.. _simplejson version 2.0.9: http://pypi.python.org/pypi/simplejson/2.0.9
.. _test: http://packages.python.org/distribute/setuptools.html#test
.. _tox: http://pypi.python.org/pypi/tox
.. _version 1.0.3: https://github.com/mustache/spec/tree/48c933b0bb780875acbfd15816297e263c53d6f7
......@@ -7,4 +7,3 @@ TODO
* 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.
* Add a unittest that pystache.__version__ matches the version in setup.py.
......@@ -9,15 +9,16 @@ This module is for our test console script.
import os
import sys
import unittest
from unittest import TestProgram
import pystache
from pystache.tests.common import PACKAGE_DIR, PROJECT_DIR, SPEC_TEST_DIR, UNITTEST_FILE_PREFIX
from pystache.tests.common import get_module_names
from pystache.tests.doctesting import get_doctests
from pystache.tests.spectesting import get_spec_tests
# TODO: enhance this function to create spec-test tests.
def run_tests(sys_argv):
"""
Run all tests in the project.
......@@ -46,6 +47,8 @@ def run_tests(sys_argv):
# auto-detect all unit tests.
module_names = _discover_test_modules(PACKAGE_DIR)
sys_argv.extend(module_names)
# Add the current module for unit tests contained here.
sys_argv.append(__name__)
_PystacheTestProgram._text_doctest_dir = project_dir
_PystacheTestProgram._spec_test_dir = spec_test_dir
......@@ -78,6 +81,19 @@ def _discover_test_modules(package_dir):
return names
class SetupTests(unittest.TestCase):
"""Tests about setup.py."""
def test_version(self):
"""
Test that setup.py's version matches the package's version.
"""
from setup import VERSION
self.assertEqual(VERSION, pystache.__version__)
# The function unittest.main() is an alias for unittest.TestProgram's
# constructor. TestProgram's constructor calls self.runTests() as its
# final step, which expects self.test to be set. The constructor sets
......
......@@ -61,6 +61,9 @@ def get_spec_tests(spec_test_dir):
Return a list of unittest.TestCase instances.
"""
# TODO: use logging module instead.
print "pystache: spec tests: using %s" % _get_parser_info()
cases = []
# Make this absolute for easier diagnosis in case of error.
......@@ -90,6 +93,10 @@ def get_spec_tests(spec_test_dir):
return cases
def _get_parser_info():
return "%s (version %s)" % (parser.__name__, parser.__version__)
def _read_spec_tests(path):
"""
Return a list of unittest.TestCase instances.
......@@ -231,8 +238,9 @@ class SpecTestBase(unittest.TestCase, AssertStringMixin):
def escape(s):
return s.replace("%", "%%")
parser_info = _get_parser_info()
subs = [repr(test_name), description, os.path.abspath(file_path),
template, repr(context), parser.__version__, str(parser)]
template, repr(context), parser_info]
subs = tuple([escape(sub) for sub in subs])
# We include the parsing module version info to help with troubleshooting
# yaml/json/simplejson issues.
......@@ -246,7 +254,7 @@ class SpecTestBase(unittest.TestCase, AssertStringMixin):
%%s
(using version %s of %s)
[using %s]
""" % subs
self.assertString(actual, expected, format=message)
[nosetests]
with-doctest=1
doctest-extension=rst
# Prevent nose from interpreting the load_tests protocol function as a test.
exclude=load_tests
......@@ -52,10 +52,11 @@ else:
setup = dist.setup
# TODO: use the logging module instead of printing.
print("Using: version %s of %s" % (repr(dist.__version__), repr(dist)))
# TODO: include the following in a verbose mode.
# print("Using: version %s of %s" % (repr(dist.__version__), repr(dist)))
VERSION = '0.5.1-alpha' # Also change in pystache/init.py.
VERSION = '0.5.1-alpha' # Also change in pystache/__init__.py.
HISTORY_PATH = 'HISTORY.rst'
LICENSE_PATH = 'LICENSE'
......@@ -134,7 +135,6 @@ else:
extra = {
# Causes 2to3 to be run during the build step.
'use_2to3': True,
'convert_2to3_doctests': [README_PATH],
}
# We use the package simplejson for older Python versions since Python
......@@ -151,8 +151,6 @@ if py_version < (2, 5):
requires.append('simplejson<2.1')
elif py_version < (2, 6):
requires.append('simplejson')
else:
requires.append('pyyaml')
INSTALL_REQUIRES = requires
......@@ -188,7 +186,6 @@ def main(sys_argv):
'pystache.tests.data.locator': template_files,
'pystache.tests.examples': template_files,
},
test_suite='pystache.tests',
entry_points = {
'console_scripts': [
'pystache=pystache.commands.render:main',
......
......@@ -3,7 +3,7 @@
# http://pypi.python.org/pypi/tox
#
[tox]
envlist = py24,py25,py26,py27,py31,py32
envlist = py24,py25,py26,py27,py27-yaml,py31,py32
[testenv]
# Change the working directory so that we don't import the pystache located
......@@ -12,3 +12,12 @@ changedir =
{envbindir}
commands =
pystache-test {toxinidir} {toxinidir}/ext/spec/specs
# Check that the spec tests work with PyYAML.
[testenv:py27-yaml]
deps =
PyYAML
changedir =
{envbindir}
commands =
pystache-test {toxinidir} {toxinidir}/ext/spec/specs
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