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
fb12f8a6
Commit
fb12f8a6
authored
Apr 21, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The project directory can now be passed to pystache-test (for doctest purposes).
parent
728f6262
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
pystache/tests/doctesting.py
+4
-6
pystache/tests/main.py
+11
-2
No files found.
pystache/tests/doctesting.py
View file @
fb12f8a6
...
...
@@ -10,14 +10,14 @@ import pkgutil
import
doctest
import
traceback
from
pystache.tests.common
import
PACKAGE_DIR
,
PROJECT_DIR
,
TEXT_DOCTEST_PATHS
from
pystache.tests.common
import
PACKAGE_DIR
,
TEXT_DOCTEST_PATHS
# This module follows the guidance documented here:
#
# http://docs.python.org/library/doctest.html#unittest-api
#
def
get_module_doctests
():
def
get_module_doctests
(
project_dir
):
"""
Return a list of TestSuite instances for all doctests in the pacakqge.
...
...
@@ -25,13 +25,11 @@ def get_module_doctests():
suites
=
[]
# Since module_relative is False in our calls to DocFileSuite below,
# paths should be OS-specific. Moreover, we choose absolute paths
# so that the current working directory does not come into play.
# See the following for more info--
# paths should be OS-specific. See the following for more info--
#
# http://docs.python.org/library/doctest.html#doctest.DocFileSuite
#
paths
=
[
os
.
path
.
join
(
PROJECT_DIR
,
path
)
for
path
in
TEXT_DOCTEST_PATHS
]
paths
=
[
os
.
path
.
normpath
(
os
.
path
.
join
(
project_dir
,
path
)
)
for
path
in
TEXT_DOCTEST_PATHS
]
for
path
in
paths
:
suite
=
doctest
.
DocFileSuite
(
path
,
module_relative
=
False
)
suites
.
append
(
suite
)
...
...
pystache/tests/main.py
View file @
fb12f8a6
...
...
@@ -11,7 +11,7 @@ import os
import
sys
from
unittest
import
TestProgram
from
pystache.tests.common
import
PACKAGE_DIR
from
pystache.tests.common
import
PACKAGE_DIR
,
PROJECT_DIR
from
pystache.tests.doctesting
import
get_module_doctests
...
...
@@ -27,12 +27,21 @@ def run_tests(sys_argv):
sys_argv: a reference to sys.argv.
"""
try
:
# TODO: use optparse command options instead.
project_dir
=
sys_argv
[
1
]
sys_argv
.
pop
()
except
IndexError
:
project_dir
=
PROJECT_DIR
if
len
(
sys_argv
)
<=
1
or
sys_argv
[
-
1
]
.
startswith
(
"-"
):
# Then no explicit module or test names were provided, so
# auto-detect all unit tests.
module_names
=
_discover_test_modules
(
PACKAGE_DIR
)
sys_argv
.
extend
(
module_names
)
_PystacheTestProgram
.
_project_dir
=
project_dir
# We pass None for the module because we do not want the unittest
# module to resolve module names relative to a given module.
# (This would require importing all of the unittest modules from
...
...
@@ -136,7 +145,7 @@ class _PystacheTestProgram(TestProgram):
"""
def
runTests
(
self
):
doctest_suites
=
get_module_doctests
()
doctest_suites
=
get_module_doctests
(
self
.
_project_dir
)
# self.test is a unittest.TestSuite instance:
# http://docs.python.org/library/unittest.html#unittest.TestSuite
self
.
test
.
addTests
(
doctest_suites
)
...
...
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