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
ff36b627
Commit
ff36b627
authored
12 years ago
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test scripts now work with and without source.
parent
9447214e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
9 deletions
+51
-9
MANIFEST.in
+1
-0
pystache/tests/main.py
+25
-4
setup.py
+1
-1
test_pystache.py
+10
-1
tox.ini
+14
-3
No files found.
MANIFEST.in
View file @
ff36b627
...
@@ -2,6 +2,7 @@ include LICENSE
...
@@ -2,6 +2,7 @@ include LICENSE
include HISTORY.rst
include HISTORY.rst
include README.rst
include README.rst
include tox.ini
include tox.ini
include test_pystache.py
# You cannot use package_data, for example, to include data files in a
# You cannot use package_data, for example, to include data files in a
# source distribution when using Distribute.
# source distribution when using Distribute.
recursive-include pystache/tests *.mustache *.txt
recursive-include pystache/tests *.mustache *.txt
This diff is collapsed.
Click to expand it.
pystache/tests/main.py
View file @
ff36b627
...
@@ -19,6 +19,11 @@ from pystache.tests.doctesting import get_doctests
...
@@ -19,6 +19,11 @@ from pystache.tests.doctesting import get_doctests
from
pystache.tests.spectesting
import
get_spec_tests
from
pystache.tests.spectesting
import
get_spec_tests
# If this command option is present, then the spec test and doctest directories
# will be inserted if not provided.
FROM_SOURCE_OPTION
=
"--from-source"
def
run_tests
(
sys_argv
):
def
run_tests
(
sys_argv
):
"""
"""
Run all tests in the project.
Run all tests in the project.
...
@@ -28,25 +33,39 @@ def run_tests(sys_argv):
...
@@ -28,25 +33,39 @@ def run_tests(sys_argv):
sys_argv: a reference to sys.argv.
sys_argv: a reference to sys.argv.
"""
"""
should_source_exist
=
False
spec_test_dir
=
None
project_dir
=
None
if
len
(
sys_argv
)
>
1
and
sys_argv
[
1
]
==
FROM_SOURCE_OPTION
:
should_source_exist
=
True
sys_argv
.
pop
(
1
)
# TODO: use logging module
print
"pystache: running tests: expecting source:
%
s"
%
should_source_exist
try
:
try
:
# TODO: use optparse command options instead.
# TODO: use optparse command options instead.
projec
t_dir
=
sys_argv
[
1
]
spec_tes
t_dir
=
sys_argv
[
1
]
sys_argv
.
pop
(
1
)
sys_argv
.
pop
(
1
)
except
IndexError
:
except
IndexError
:
project_dir
=
PROJECT_DIR
if
should_source_exist
:
spec_test_dir
=
SPEC_TEST_DIR
try
:
try
:
# TODO: use optparse command options instead.
# TODO: use optparse command options instead.
spec_tes
t_dir
=
sys_argv
[
1
]
projec
t_dir
=
sys_argv
[
1
]
sys_argv
.
pop
(
1
)
sys_argv
.
pop
(
1
)
except
IndexError
:
except
IndexError
:
spec_test_dir
=
SPEC_TEST_DIR
if
should_source_exist
:
project_dir
=
PROJECT_DIR
if
len
(
sys_argv
)
<=
1
or
sys_argv
[
-
1
]
.
startswith
(
"-"
):
if
len
(
sys_argv
)
<=
1
or
sys_argv
[
-
1
]
.
startswith
(
"-"
):
# Then no explicit module or test names were provided, so
# Then no explicit module or test names were provided, so
# auto-detect all unit tests.
# auto-detect all unit tests.
module_names
=
_discover_test_modules
(
PACKAGE_DIR
)
module_names
=
_discover_test_modules
(
PACKAGE_DIR
)
sys_argv
.
extend
(
module_names
)
sys_argv
.
extend
(
module_names
)
if
project_dir
is
not
None
:
# Add the current module for unit tests contained here.
# Add the current module for unit tests contained here.
sys_argv
.
append
(
__name__
)
sys_argv
.
append
(
__name__
)
...
@@ -123,9 +142,11 @@ class _PystacheTestProgram(TestProgram):
...
@@ -123,9 +142,11 @@ class _PystacheTestProgram(TestProgram):
# http://docs.python.org/library/unittest.html#unittest.TestSuite
# http://docs.python.org/library/unittest.html#unittest.TestSuite
tests
=
self
.
test
tests
=
self
.
test
if
self
.
_text_doctest_dir
is
not
None
:
doctest_suites
=
get_doctests
(
self
.
_text_doctest_dir
)
doctest_suites
=
get_doctests
(
self
.
_text_doctest_dir
)
tests
.
addTests
(
doctest_suites
)
tests
.
addTests
(
doctest_suites
)
if
self
.
_spec_test_dir
is
not
None
:
spec_testcases
=
get_spec_tests
(
self
.
_spec_test_dir
)
spec_testcases
=
get_spec_tests
(
self
.
_spec_test_dir
)
tests
.
addTests
(
spec_testcases
)
tests
.
addTests
(
spec_testcases
)
...
...
This diff is collapsed.
Click to expand it.
setup.py
View file @
ff36b627
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# coding: utf-8
# coding: utf-8
"""
"""
This script supports
distributing Pystache and testing it from a source distribution
.
This script supports
publishing Pystache to PyPI
.
Below are instructions to pystache maintainers on how to push a new
Below are instructions to pystache maintainers on how to push a new
version of pystache to PyPI--
version of pystache to PyPI--
...
...
This diff is collapsed.
Click to expand it.
test_pystache.py
View file @
ff36b627
...
@@ -15,7 +15,16 @@ in Python 2.4:
...
@@ -15,7 +15,16 @@ in Python 2.4:
"""
"""
from
pystache.commands.test
import
main
import
sys
from
pystache.commands
import
test
from
pystache.tests.main
import
FROM_SOURCE_OPTION
def
main
(
sys_argv
=
sys
.
argv
):
sys
.
argv
.
insert
(
1
,
FROM_SOURCE_OPTION
)
test
.
main
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
This diff is collapsed.
Click to expand it.
tox.ini
View file @
ff36b627
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# http://pypi.python.org/pypi/tox
# http://pypi.python.org/pypi/tox
#
#
[tox]
[tox]
envlist
=
py24,py25,py26,py27,py27-yaml,py31,py32
envlist
=
py24,py25,py26,py27,py27-yaml,py
27-noargs,py
31,py32
[testenv]
[testenv]
# Change the working directory so that we don't import the pystache located
# Change the working directory so that we don't import the pystache located
...
@@ -11,13 +11,24 @@ envlist = py24,py25,py26,py27,py27-yaml,py31,py32
...
@@ -11,13 +11,24 @@ envlist = py24,py25,py26,py27,py27-yaml,py31,py32
changedir
=
changedir
=
{envbindir}
{envbindir}
commands
=
commands
=
pystache-test
{toxinidir}
{toxinidir}/ext/spec/specs
pystache-test
{toxinidir}/ext/spec/specs
{toxinidir}
# Check that the spec tests work with PyYAML.
# Check that the spec tests work with PyYAML.
[testenv:py27-yaml]
[testenv:py27-yaml]
basepython
=
python2.7
deps
=
deps
=
PyYAML
PyYAML
changedir
=
changedir
=
{envbindir}
{envbindir}
commands
=
commands
=
pystache-test
{toxinidir}
{toxinidir}/ext/spec/specs
pystache-test
{toxinidir}/ext/spec/specs
{toxinidir}
# Check that pystache-test works from an install with no arguments.
[testenv:py27-noargs]
basepython
=
python2.7
changedir
=
{envbindir}
commands
=
pystache-test
This diff is collapsed.
Click to expand it.
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