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
3e2ee32d
Commit
3e2ee32d
authored
Apr 20, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced the TestHarness class with a run_tests() function.
parent
3e20e423
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
35 deletions
+27
-35
pystache/commands/test.py
+2
-3
pystache/tests/main.py
+25
-32
No files found.
pystache/commands/test.py
View file @
3e2ee32d
...
@@ -7,12 +7,11 @@ This module provides a command to test pystache (unit tests, doctests, etc).
...
@@ -7,12 +7,11 @@ This module provides a command to test pystache (unit tests, doctests, etc).
import
sys
import
sys
from
pystache.tests.main
import
TestHarnes
s
from
pystache.tests.main
import
run_test
s
def
main
(
sys_argv
=
sys
.
argv
):
def
main
(
sys_argv
=
sys
.
argv
):
harness
=
TestHarness
()
run_tests
(
sys_argv
=
sys_argv
)
harness
.
run_tests
(
sys_argv
=
sys_argv
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
pystache/tests/main.py
View file @
3e2ee32d
# coding: utf-8
# coding: utf-8
"""
"""
Allows all tests to be run
.
Exposes a run_tests() function that runs all tests in the project
.
This module is for our test console script.
This module is for our test console script.
...
@@ -34,6 +34,30 @@ UNITTEST_FILE_PREFIX = "test_"
...
@@ -34,6 +34,30 @@ UNITTEST_FILE_PREFIX = "test_"
# TestCase or TestSuite instances (e.g. doctests and spec tests), and then
# TestCase or TestSuite instances (e.g. doctests and spec tests), and then
# call the base class's runTests().
# call the base class's runTests().
def
run_tests
(
sys_argv
):
"""
Run all tests in the project.
Arguments:
sys_argv: a reference to sys.argv.
"""
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
)
# 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
# this module.) See the loadTestsFromName() method of the
# unittest.TestLoader class for more details on this parameter.
_PystacheTestProgram
(
argv
=
sys_argv
,
module
=
None
)
# No need to return since unitttest.main() exits.
def
_find_unittest_files
(
package_dir
):
def
_find_unittest_files
(
package_dir
):
"""
"""
Return a list of paths to all unit-test files in the given package directory.
Return a list of paths to all unit-test files in the given package directory.
...
@@ -125,34 +149,3 @@ class _PystacheTestProgram(TestProgram):
...
@@ -125,34 +149,3 @@ class _PystacheTestProgram(TestProgram):
self
.
test
.
addTests
(
doctest_suites
)
self
.
test
.
addTests
(
doctest_suites
)
TestProgram
.
runTests
(
self
)
TestProgram
.
runTests
(
self
)
class
TestHarness
(
object
):
"""
Discovers and runs unit tests.
"""
def
run_tests
(
self
,
sys_argv
):
"""
Run all unit tests inside the given package.
Arguments:
sys_argv: a reference to sys.argv.
"""
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
)
# 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
# this module.) See the loadTestsFromName() method of the
# unittest.TestLoader class for more details on this parameter.
_PystacheTestProgram
(
argv
=
sys_argv
,
module
=
None
)
# No need to return since unitttest.main() exits.
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