Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
4241de51
Commit
4241de51
authored
Jul 29, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added doctest support to runtests.py
parent
68ecd7c5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
runtests.py
runtests.py
+32
-0
No files found.
runtests.py
View file @
4241de51
...
@@ -309,6 +309,32 @@ def collect_unittests(path, module_prefix, suite, selectors):
...
@@ -309,6 +309,32 @@ def collect_unittests(path, module_prefix, suite, selectors):
module
=
getattr
(
module
,
x
)
module
=
getattr
(
module
,
x
)
suite
.
addTests
([
loader
.
loadTestsFromModule
(
module
)])
suite
.
addTests
([
loader
.
loadTestsFromModule
(
module
)])
def
collect_doctests
(
path
,
module_prefix
,
suite
,
selectors
):
def
package_matches
(
dirname
):
return
dirname
not
in
(
"Mac"
,
"Distutils"
,
"Plex"
)
def
file_matches
(
filename
):
return
(
filename
.
endswith
(
".py"
)
and
not
(
'~'
in
filename
or
'#'
in
filename
or
filename
.
startswith
(
'.'
)))
import
doctest
,
types
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
path
):
parentname
=
os
.
path
.
split
(
dirpath
)[
-
1
]
if
package_matches
(
parentname
):
for
f
in
filenames
:
if
file_matches
(
f
):
if
not
f
.
endswith
(
'.py'
):
continue
filepath
=
os
.
path
.
join
(
dirpath
,
f
)[:
-
len
(
".py"
)]
modulename
=
module_prefix
+
filepath
[
len
(
path
)
+
1
:].
replace
(
os
.
path
.
sep
,
'.'
)
if
not
[
1
for
match
in
selectors
if
match
(
modulename
)
]:
continue
module
=
__import__
(
modulename
)
for
x
in
modulename
.
split
(
'.'
)[
1
:]:
module
=
getattr
(
module
,
x
)
if
hasattr
(
module
,
"__doc__"
)
or
hasattr
(
module
,
"__test__"
):
try
:
suite
.
addTests
(
doctest
.
DocTestSuite
(
module
))
except
ValueError
:
# no tests
pass
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
from
optparse
import
OptionParser
from
optparse
import
OptionParser
parser
=
OptionParser
()
parser
=
OptionParser
()
...
@@ -324,6 +350,9 @@ if __name__ == '__main__':
...
@@ -324,6 +350,9 @@ if __name__ == '__main__':
parser
.
add_option
(
"--no-unit"
,
dest
=
"unittests"
,
parser
.
add_option
(
"--no-unit"
,
dest
=
"unittests"
,
action
=
"store_false"
,
default
=
True
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the unit tests"
)
help
=
"do not run the unit tests"
)
parser
.
add_option
(
"--no-doctest"
,
dest
=
"doctests"
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the doctests"
)
parser
.
add_option
(
"--no-file"
,
dest
=
"filetests"
,
parser
.
add_option
(
"--no-file"
,
dest
=
"filetests"
,
action
=
"store_false"
,
default
=
True
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the file based tests"
)
help
=
"do not run the file based tests"
)
...
@@ -386,6 +415,9 @@ if __name__ == '__main__':
...
@@ -386,6 +415,9 @@ if __name__ == '__main__':
if
options
.
unittests
:
if
options
.
unittests
:
collect_unittests
(
UNITTEST_ROOT
,
UNITTEST_MODULE
+
"."
,
test_suite
,
selectors
)
collect_unittests
(
UNITTEST_ROOT
,
UNITTEST_MODULE
+
"."
,
test_suite
,
selectors
)
if
options
.
doctests
:
collect_doctests
(
UNITTEST_ROOT
,
UNITTEST_MODULE
+
"."
,
test_suite
,
selectors
)
if
options
.
filetests
:
if
options
.
filetests
:
filetests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
filetests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
options
.
annotate_source
,
options
.
cleanup_workdir
,
options
.
annotate_source
,
options
.
cleanup_workdir
,
...
...
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