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
Boxiang Sun
cython
Commits
c75803ed
Commit
c75803ed
authored
Jun 19, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit tests to test runner
parent
45aed36f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
3 deletions
+36
-3
runtests.py
runtests.py
+36
-3
No files found.
runtests.py
View file @
c75803ed
...
...
@@ -238,6 +238,27 @@ class CythonRunTestCase(CythonCompileTestCase):
except
Exception
:
pass
def
collect_unittests
(
path
,
suite
):
def
file_matches
(
filename
):
return
filename
.
startswith
(
"Test"
)
and
filename
.
endswith
(
".py"
)
def
package_matches
(
dirname
):
return
dirname
==
"Tests"
loader
=
unittest
.
TestLoader
()
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
):
filepath
=
os
.
path
.
join
(
dirpath
,
f
)[:
-
len
(
".py"
)]
modulename
=
filepath
[
len
(
path
)
+
1
:].
replace
(
os
.
path
.
sep
,
'.'
)
module
=
__import__
(
modulename
)
for
x
in
modulename
.
split
(
'.'
)[
1
:]:
module
=
getattr
(
module
,
x
)
suite
.
addTests
(
loader
.
loadTestsFromModule
(
module
))
if
__name__
==
'__main__'
:
from
optparse
import
OptionParser
parser
=
OptionParser
()
...
...
@@ -247,6 +268,12 @@ if __name__ == '__main__':
parser
.
add_option
(
"--no-cython"
,
dest
=
"with_cython"
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the Cython compiler, only the C compiler"
)
parser
.
add_option
(
"--no-unit"
,
dest
=
"unittests"
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the unit tests"
)
parser
.
add_option
(
"--no-file"
,
dest
=
"filetests"
,
action
=
"store_false"
,
default
=
True
,
help
=
"do not run the file based tests"
)
parser
.
add_option
(
"-C"
,
"--coverage"
,
dest
=
"coverage"
,
action
=
"store_true"
,
default
=
False
,
help
=
"collect source coverage data for the Compiler"
)
...
...
@@ -296,9 +323,15 @@ if __name__ == '__main__':
if
not
selectors
:
selectors
=
[
lambda
x
:
True
]
tests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
options
.
annotate_source
,
options
.
cleanup_workdir
)
test_suite
=
tests
.
build_suite
()
test_suite
=
unittest
.
TestSuite
()
if
options
.
unittests
:
collect_unittests
(
os
.
getcwd
(),
test_suite
)
if
options
.
filetests
:
filetests
=
TestBuilder
(
ROOTDIR
,
WORKDIR
,
selectors
,
options
.
annotate_source
,
options
.
cleanup_workdir
)
test_suite
.
addTests
(
filetests
.
build_suite
())
unittest
.
TextTestRunner
(
verbosity
=
options
.
verbosity
).
run
(
test_suite
)
...
...
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