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
3e20e423
Commit
3e20e423
authored
Apr 20, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed test_doctests.py (and use of the load_tests protocol).
parent
60a6c396
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
48 deletions
+13
-48
pystache/commands/test.py
+3
-4
pystache/tests/main.py
+10
-9
pystache/tests/test_doctests.py
+0
-35
No files found.
pystache/commands/test.py
View file @
3e20e423
...
@@ -7,13 +7,12 @@ This module provides a command to test pystache (unit tests, doctests, etc).
...
@@ -7,13 +7,12 @@ This module provides a command to test pystache (unit tests, doctests, etc).
import
sys
import
sys
import
pystache
from
pystache.tests.main
import
TestHarness
from
pystache.tests.main
import
Tester
def
main
(
sys_argv
=
sys
.
argv
):
def
main
(
sys_argv
=
sys
.
argv
):
tester
=
Tester
()
harness
=
TestHarness
()
tester
.
run_tests
(
package
=
pystache
,
sys_argv
=
sys_argv
)
harness
.
run_tests
(
sys_argv
=
sys_argv
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
pystache/tests/main.py
View file @
3e20e423
...
@@ -11,6 +11,9 @@ import os
...
@@ -11,6 +11,9 @@ import os
import
sys
import
sys
from
unittest
import
TestProgram
from
unittest
import
TestProgram
from
pystache.tests.common
import
PACKAGE_DIR
from
pystache.tests.doctesting
import
get_module_doctests
UNITTEST_FILE_PREFIX
=
"test_"
UNITTEST_FILE_PREFIX
=
"test_"
...
@@ -93,12 +96,11 @@ def _get_test_module_names(package_dir):
...
@@ -93,12 +96,11 @@ def _get_test_module_names(package_dir):
return
modules
return
modules
def
_discover_test_modules
(
package
):
def
_discover_test_modules
(
package
_dir
):
"""
"""
Discover and return a sorted list of the names of unit-test modules.
Discover and return a sorted list of the names of unit-test modules.
"""
"""
package_dir
=
os
.
path
.
dirname
(
package
.
__file__
)
modules
=
_get_test_module_names
(
package_dir
)
modules
=
_get_test_module_names
(
package_dir
)
modules
.
sort
()
modules
.
sort
()
...
@@ -119,33 +121,32 @@ class _PystacheTestProgram(TestProgram):
...
@@ -119,33 +121,32 @@ class _PystacheTestProgram(TestProgram):
"""
"""
def
runTests
(
self
):
def
runTests
(
self
):
# TODO: add doctests, etc. to the self.test TestSuite.
doctest_suites
=
get_module_doctests
()
self
.
test
.
addTests
(
doctest_suites
)
TestProgram
.
runTests
(
self
)
TestProgram
.
runTests
(
self
)
class
Test
er
(
object
):
class
Test
Harness
(
object
):
"""
"""
Discovers and runs unit tests.
Discovers and runs unit tests.
"""
"""
# TODO: consider replacing the package argument with a package_dir argument.
def
run_tests
(
self
,
sys_argv
):
def
run_tests
(
self
,
package
,
sys_argv
):
"""
"""
Run all unit tests inside the given package.
Run all unit tests inside the given package.
Arguments:
Arguments:
package: a module instance corresponding to the package.
sys_argv: a reference to sys.argv.
sys_argv: a reference to sys.argv.
"""
"""
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
)
module_names
=
_discover_test_modules
(
PACKAGE_DIR
)
sys_argv
.
extend
(
module_names
)
sys_argv
.
extend
(
module_names
)
# We pass None for the module because we do not want the unittest
# We pass None for the module because we do not want the unittest
...
...
pystache/tests/test_doctests.py
deleted
100644 → 0
View file @
60a6c396
# coding: utf-8
"""
Creates unittest.TestSuite instances for the doctests in the project.
"""
from
pystache.tests.doctesting
import
get_module_doctests
# The following load_tests() function implements unittests's load_tests
# protocol added in Python 2.7:
#
# http://docs.python.org/library/unittest.html#load-tests-protocol
#
# Using this protocol lets us include the doctests in test runs without
# using nose, for example when using Distribute's test as in the following:
#
# python setup.py test
#
# Normally, nosetests would interpret this function as a test case (because
# its name matches the test regular expression) and call it with zero arguments
# as opposed to the required three. However, we are able to exclude it with
# an entry like the following in setup.cfg:
#
# exclude=load_tests
#
# TODO: find a substitute for the load_tests protocol for Python versions
# before version 2.7.
#
def
load_tests
(
loader
,
tests
,
ignore
):
suites
=
get_module_doctests
()
tests
.
addTests
(
suites
)
return
tests
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