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
8aa242e9
Commit
8aa242e9
authored
Apr 20, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished refactoring pystache/tests/main.py prior to add doctest support, etc.
parent
d9e84960
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
pystache/tests/main.py
+22
-17
No files found.
pystache/tests/main.py
View file @
8aa242e9
...
@@ -94,6 +94,22 @@ def _get_test_module_names(package_dir):
...
@@ -94,6 +94,22 @@ def _get_test_module_names(package_dir):
return
modules
return
modules
def
_discover_test_modules
(
package
):
"""
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
.
sort
()
# This is a sanity check to ensure that the unit-test discovery
# methods are working.
if
len
(
modules
)
<
1
:
raise
Exception
(
"No unit-test modules found."
)
return
modules
class
_PystacheTestProgram
(
TestProgram
):
class
_PystacheTestProgram
(
TestProgram
):
pass
pass
...
@@ -118,23 +134,11 @@ class Tester(object):
...
@@ -118,23 +134,11 @@ class Tester(object):
sys_argv: a reference to sys.argv.
sys_argv: a reference to sys.argv.
"""
"""
if
len
(
sys_argv
)
>
1
and
not
sys_argv
[
-
1
]
.
startswith
(
"-"
):
if
len
(
sys_argv
)
<=
1
or
sys_argv
[
-
1
]
.
startswith
(
"-"
):
# Then explicit modules or test names were provided, which
# Then no explicit module or test names were provided, so
# the unittest module is equipped to handle.
# auto-detect all unit tests.
unittest
.
main
(
argv
=
sys_argv
,
module
=
None
)
module_names
=
_discover_test_modules
(
package
)
# No need to return since unitttest.main() exits.
sys_argv
.
extend
(
module_names
)
# Otherwise, auto-detect all unit tests.
package_dir
=
os
.
path
.
dirname
(
package
.
__file__
)
modules
=
_get_test_module_names
(
package_dir
)
modules
.
sort
()
# This is a sanity check to ensure that the unit-test discovery
# methods are working.
if
len
(
modules
)
<
1
:
raise
Exception
(
"No unit-test modules found."
)
sys_argv
.
extend
(
modules
)
# 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
# module to resolve module names relative to a given module.
# module to resolve module names relative to a given module.
...
@@ -142,3 +146,4 @@ class Tester(object):
...
@@ -142,3 +146,4 @@ class Tester(object):
# this module.) See the loadTestsFromName() method of the
# this module.) See the loadTestsFromName() method of the
# unittest.TestLoader class for more details on this parameter.
# unittest.TestLoader class for more details on this parameter.
unittest
.
main
(
argv
=
sys_argv
,
module
=
None
)
unittest
.
main
(
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