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
f267ff77
Commit
f267ff77
authored
Apr 07, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doctests now included when running `python setup.py test`.
parent
9b00a932
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
3 deletions
+32
-3
pystache/tests/common.py
+2
-1
pystache/tests/test_doctests.py
+29
-1
pystache/tests/test_spec.py
+1
-1
No files found.
pystache/tests/common.py
View file @
f267ff77
...
@@ -15,7 +15,8 @@ _TESTS_DIR = os.path.dirname(pystache.tests.__file__)
...
@@ -15,7 +15,8 @@ _TESTS_DIR = os.path.dirname(pystache.tests.__file__)
DATA_DIR
=
os
.
path
.
join
(
_TESTS_DIR
,
'data'
)
# i.e. 'pystache/tests/data'.
DATA_DIR
=
os
.
path
.
join
(
_TESTS_DIR
,
'data'
)
# i.e. 'pystache/tests/data'.
EXAMPLES_DIR
=
os
.
path
.
dirname
(
examples
.
__file__
)
EXAMPLES_DIR
=
os
.
path
.
dirname
(
examples
.
__file__
)
PROJECT_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
pystache
.
__file__
),
'..'
)
SOURCE_DIR
=
os
.
path
.
dirname
(
pystache
.
__file__
)
PROJECT_DIR
=
os
.
path
.
join
(
SOURCE_DIR
,
'..'
)
SPEC_TEST_DIR
=
os
.
path
.
join
(
PROJECT_DIR
,
'ext'
,
'spec'
,
'specs'
)
SPEC_TEST_DIR
=
os
.
path
.
join
(
PROJECT_DIR
,
'ext'
,
'spec'
,
'specs'
)
...
...
pystache/tests/test_doctests.py
View file @
f267ff77
...
@@ -12,10 +12,11 @@ Creates unittest.TestSuite instances for the doctests in the project.
...
@@ -12,10 +12,11 @@ Creates unittest.TestSuite instances for the doctests in the project.
import
os
import
os
import
doctest
import
doctest
import
pkgutil
import
unittest
import
unittest
import
pystache
import
pystache
from
pystache.tests.common
import
PROJECT_DIR
from
pystache.tests.common
import
PROJECT_DIR
,
SOURCE_DIR
# The paths to text files (i.e. non-module files) containing doctests.
# The paths to text files (i.e. non-module files) containing doctests.
...
@@ -34,4 +35,31 @@ def load_tests(loader, tests, ignore):
...
@@ -34,4 +35,31 @@ def load_tests(loader, tests, ignore):
paths
=
[
os
.
path
.
join
(
PROJECT_DIR
,
path
)
for
path
in
text_file_paths
]
paths
=
[
os
.
path
.
join
(
PROJECT_DIR
,
path
)
for
path
in
text_file_paths
]
tests
.
addTests
(
doctest
.
DocFileSuite
(
*
paths
,
module_relative
=
False
))
tests
.
addTests
(
doctest
.
DocFileSuite
(
*
paths
,
module_relative
=
False
))
modules
=
get_module_doctests
()
for
module
in
modules
:
suite
=
doctest
.
DocTestSuite
(
module
)
tests
.
addTests
(
suite
)
return
tests
return
tests
def
get_module_doctests
():
modules
=
[]
for
pkg
in
pkgutil
.
walk_packages
([
SOURCE_DIR
]):
# The importer is a pkgutil.ImpImporter instance:
#
# http://docs.python.org/library/pkgutil.html#pkgutil.ImpImporter
#
importer
,
module_name
,
is_package
=
pkg
if
is_package
:
# Otherwise, we will get the following error when adding tests:
#
# ValueError: (<module 'tests' from '.../pystache/tests/__init__.pyc'>, 'has no tests')
#
continue
# The loader is a pkgutil.ImpLoader instance.
loader
=
importer
.
find_module
(
module_name
)
module
=
loader
.
load_module
(
module_name
)
modules
.
append
(
module
)
return
modules
pystache/tests/test_spec.py
View file @
f267ff77
...
@@ -35,7 +35,7 @@ spec_paths = glob.glob(os.path.join(SPEC_TEST_DIR, '*.json'))
...
@@ -35,7 +35,7 @@ spec_paths = glob.glob(os.path.join(SPEC_TEST_DIR, '*.json'))
# This test case lets us alert the user that spec tests are missing.
# This test case lets us alert the user that spec tests are missing.
class
CheckSpecTestsFound
(
unittest
.
TestCase
):
class
CheckSpecTestsFound
(
unittest
.
TestCase
):
def
test_spec_tests_
exist
(
self
):
def
test_spec_tests_
found
(
self
):
if
len
(
spec_paths
)
>
0
:
if
len
(
spec_paths
)
>
0
:
return
return
raise
Exception
(
"Spec tests not found in:
%
s
\n
"
raise
Exception
(
"Spec tests not found in:
%
s
\n
"
...
...
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