Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
e3f0abe4
Commit
e3f0abe4
authored
Apr 10, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-107-tox-support' into 'development': addressed issue #107
parents
f124d46e
954cebfc
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
116 additions
and
40 deletions
+116
-40
.gitignore
+1
-0
HISTORY.rst
+1
-0
README.rst
+25
-29
pystache/defaults.py
+7
-0
pystache/init.py
+2
-1
pystache/tests/test_renderer.py
+2
-2
setup.py
+46
-8
tox.ini
+32
-0
No files found.
.gitignore
View file @
e3f0abe4
*.pyc
.tox
build
MANIFEST
dist
...
...
HISTORY.rst
View file @
e3f0abe4
...
...
@@ -6,6 +6,7 @@ History
* Added support for Python 3.2 (following conversion with 2to3_).
* Test runner now supports both yaml and json forms of Mustache spec.
* Added tox support to test multiple Python versions.
0.5.0 (2012-04-03)
------------------
...
...
README.rst
View file @
e3f0abe4
...
...
@@ -134,50 +134,44 @@ default to values set in Pystache's ``defaults`` module.
Test It
=======
Pystache can be tested using both Python 2 and 3 -- even from a single
Python 2 install if using Distribute's ``test`` (see below).
Use tox_ to test Pystache with multiple versions of Python all at once! ::
pip install tox
tox
If you do not have all Python versions listed in ``tox.in``, then
tox -e py26,py27 # for example
To include tests from the Mustache spec in your test runs: ::
git submodule init
git submodule update
You can also test Pystache without tox (but with only a single version of
Python at a time), as below. To do this, install Distribute_ ::
Python 3
--------
For Python 3, we recommend installing and using Distribute_.
Then one can invoke `Distribute's test`_ command: ::
python setup.py test
pip install distribute
Python 2
--------
Python 2
.7 and Later
--------
------------
For Python 2, we recommend nose
_: ::
Then run Distribute's test
_: ::
pip install nose
cd pystache
nosetests
Depending on your Python version and nose installation, you may need
to type, for example-- ::
python setup.py test
nosetests-2.4
This runs 2to3_ when using Python 3.
To run all available tests (including doctests)-- ::
nosetests --with-doctest --doctest-extension=rst
Python 2.6 and Earlier
----------------------
or alternatively (using setup.cfg)--
::
For Python 2.6 and earlier, use nose_ instead of ``test``:
::
pip install nose
python setup.py nosetests
To run a subset of the tests, you can use this pattern, for example-- ::
nosetests --tests tests/test_context.py:GetValueTests.test_dictionary__key_present
Mailing List
============
...
...
@@ -200,20 +194,22 @@ Author
Chris Wanstrath :: chris@ozmm.org
.. _2to3: http://docs.python.org/library/2to3.html
.. _built-in unicode function: http://docs.python.org/library/functions.html#unicode
.. _ctemplate: http://code.google.com/p/google-ctemplate/
.. _David Phillips: http://davidphillips.us/
.. _Distribute: http://pypi.python.org/pypi/distribute
.. _Distribute's test: http://packages.python.org/distribute/setuptools.html#test
.. _et: http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html
.. _json: http://docs.python.org/library/json.html
.. _Mustache: http://mustache.github.com/
.. _Mustache spec: https://github.com/mustache/spec
.. _mustache(5): http://mustache.github.com/mustache.5.html
.. _nose: http://
somethingaboutorange.com/mrl/projects/nose/0.11.1/testing.html
.. _nose: http://
readthedocs.org/docs/nose/en/latest/
.. _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
.. _semantically versioned: http://semver.org
.. _simplejson: http://pypi.python.org/pypi/simplejson/
.. _built-in unicode function: http://docs.python.org/library/functions.html#unicode
.. _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
pystache/defaults.py
View file @
e3f0abe4
...
...
@@ -11,6 +11,13 @@ does not otherwise specify a value.
try
:
# Python 3.2 deprecates cgi.escape() and adds the html module as a replacement.
import
html
try
:
# We also need to verify the existence of the escape() method
# due to the following issue:
# http://bugs.python.org/issue14545
html
.
escape
except
AttributeError
:
raise
ImportError
(
"html.escape does not exist"
)
except
ImportError
:
import
cgi
as
html
...
...
pystache/init.py
View file @
e3f0abe4
...
...
@@ -9,8 +9,9 @@ from pystache.renderer import Renderer
from
pystache.template_spec
import
TemplateSpec
__all__
=
[
'render'
,
'Renderer'
,
'TemplateSpec'
]
__all__
=
[
'
__version__'
,
'
render'
,
'Renderer'
,
'TemplateSpec'
]
__version__
=
'0.5.0-rc'
# Also change in setup.py.
def
render
(
template
,
context
=
None
,
**
kwargs
):
"""
...
...
pystache/tests/test_renderer.py
View file @
e3f0abe4
...
...
@@ -63,8 +63,8 @@ class RendererInitTestCase(unittest.TestCase):
self
.
assertEqual
(
escape
(
">"
),
">"
)
self
.
assertEqual
(
escape
(
'"'
),
"""
)
# Single quotes are escaped
in Python 3 but not Python 2
.
if
sys
.
version_info
<
(
3
,
):
# Single quotes are escaped
only in Python 3.2 and later
.
if
sys
.
version_info
<
(
3
,
2
):
expected
=
"'"
else
:
expected
=
'''
...
...
setup.py
View file @
e3f0abe4
...
...
@@ -38,15 +38,23 @@ as described here, for example:
import
os
import
sys
try
:
py_version
=
sys
.
version_info
# Distribute works with Python 2.3.5 and above:
# http://packages.python.org/distribute/setuptools.html#building-and-distributing-packages-with-distribute
if
py_version
<
(
2
,
3
,
5
):
# TODO: this might not work yet.
import
distutils
as
dist
from
distutils
import
core
setup
=
core
.
setup
else
:
import
setuptools
as
dist
except
ImportError
:
from
distutils
import
core
as
dist
setup
=
dist
.
setup
# TODO: use the logging module instead.
# TODO: use the logging module instead
of printing
.
print
(
"Using: version
%
s of
%
s"
%
(
repr
(
dist
.
__version__
),
repr
(
dist
)))
setup
=
dist
.
setup
VERSION
=
'0.5.0-rc'
# Also change in pystache/init.py.
def
publish
():
...
...
@@ -80,7 +88,7 @@ template_files = ['*.mustache', '*.txt']
#
# http://packages.python.org/distribute/python3.html#note-on-compatibility-with-setuptools
#
if
sys
.
version_info
<
(
3
,
):
if
py_version
<
(
3
,
):
extra
=
{}
else
:
extra
=
{
...
...
@@ -89,6 +97,35 @@ else:
'convert_2to3_doctests'
:
[
'README.rst'
],
}
# We use the package simplejson for older Python versions since Python
# does not contain the module json before 2.6:
#
# http://docs.python.org/library/json.html
#
# Moreover, simplejson stopped officially support for Python 2.4 in version 2.1.0:
#
# https://github.com/simplejson/simplejson/blob/master/CHANGES.txt
#
requires
=
[]
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
PACKAGES
=
[
'pystache'
,
# The following packages are only for testing.
'examples'
,
'pystache.tests'
,
'pystache.tests.data'
,
'pystache.tests.data.locator'
]
setup
(
name
=
'pystache'
,
version
=
'0.5.0-rc'
,
license
=
'MIT'
,
...
...
@@ -98,7 +135,8 @@ setup(name='pystache',
author_email
=
'chris@ozmm.org'
,
maintainer
=
'Chris Jerdonek'
,
url
=
'http://github.com/defunkt/pystache'
,
packages
=
dist
.
find_packages
(),
install_requires
=
INSTALL_REQUIRES
,
packages
=
PACKAGES
,
package_data
=
{
# Include the README so doctests can be run.
# TODO: is there a better way to include the README?
...
...
tox.ini
0 → 100644
View file @
e3f0abe4
# A tox configuration file to test across multiple Python versions.
#
# http://pypi.python.org/pypi/tox
#
[tox]
envlist
=
py24,py25,py26,py27,py31,py32
[testenv]
commands
=
python
setup.py
--quiet
test
# We use nosetests for older versions of Python to find doctests because
# the load_tests protocol (which we use for finding doctests when using
# Distribute's `test`) was not introduced until Python 2.7.
[testenv:py26]
deps
=
nose
commands
=
python
setup.py
--quiet
nosetests
[testenv:py25]
deps
=
nose
commands
=
python
setup.py
--quiet
nosetests
[testenv:py24]
deps
=
nose
commands
=
python
setup.py
--quiet
nosetests
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment