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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
e84ba16f
Commit
e84ba16f
authored
Dec 29, 2010
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve pyregr test runner: add CythonPyregrTestCase
parent
fd4f9c44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
20 deletions
+51
-20
runtests.py
runtests.py
+51
-20
No files found.
runtests.py
View file @
e84ba16f
...
@@ -189,7 +189,9 @@ class TestBuilder(object):
...
@@ -189,7 +189,9 @@ class TestBuilder(object):
if
self
.
exclude_selectors
:
if
self
.
exclude_selectors
:
if
[
1
for
match
in
self
.
exclude_selectors
if
match
(
fqmodule
)]:
if
[
1
for
match
in
self
.
exclude_selectors
if
match
(
fqmodule
)]:
continue
continue
if
context
in
TEST_RUN_DIRS
:
if
context
==
'pyregr'
:
test_class
=
CythonPyregrTestCase
elif
context
in
TEST_RUN_DIRS
:
if
module
.
startswith
(
"test_"
):
if
module
.
startswith
(
"test_"
):
test_class
=
CythonUnitTestCase
test_class
=
CythonUnitTestCase
else
:
else
:
...
@@ -462,8 +464,7 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -462,8 +464,7 @@ class CythonRunTestCase(CythonCompileTestCase):
self
.
setUp
()
self
.
setUp
()
try
:
try
:
self
.
runCompileTest
()
self
.
runCompileTest
()
if
not
self
.
cython_only
:
self
.
run_tests
(
result
)
self
.
run_doctests
(
self
.
module
,
result
)
finally
:
finally
:
check_thread_termination
()
check_thread_termination
()
except
Exception
:
except
Exception
:
...
@@ -474,6 +475,10 @@ class CythonRunTestCase(CythonCompileTestCase):
...
@@ -474,6 +475,10 @@ class CythonRunTestCase(CythonCompileTestCase):
except
Exception
:
except
Exception
:
pass
pass
def
run_tests
(
self
,
result
):
if
not
self
.
cython_only
:
self
.
run_doctests
(
self
.
module
,
result
)
def
run_doctests
(
self
,
module_name
,
result
):
def
run_doctests
(
self
,
module_name
,
result
):
if
sys
.
version_info
[
0
]
>=
3
or
not
hasattr
(
os
,
'fork'
)
or
not
self
.
fork
:
if
sys
.
version_info
[
0
]
>=
3
or
not
hasattr
(
os
,
'fork'
)
or
not
self
.
fork
:
doctest
.
DocTestSuite
(
module_name
).
run
(
result
)
doctest
.
DocTestSuite
(
module_name
).
run
(
result
)
...
@@ -621,28 +626,54 @@ class PartialTestResult(_TextTestResult):
...
@@ -621,28 +626,54 @@ class PartialTestResult(_TextTestResult):
self
.
write
(
"%s
\
n
"
%
line
)
self
.
write
(
"%s
\
n
"
%
line
)
class
CythonUnitTestCase
(
Cython
Compile
TestCase
):
class
CythonUnitTestCase
(
Cython
Run
TestCase
):
def
shortDescription
(
self
):
def
shortDescription
(
self
):
return
"compiling (%s) tests in %s"
%
(
self
.
language
,
self
.
module
)
return
"compiling (%s) tests in %s"
%
(
self
.
language
,
self
.
module
)
def
run
(
self
,
result
=
None
):
def
run_tests
(
self
,
result
):
if
result
is
None
:
unittest
.
defaultTestLoader
.
loadTestsFromName
(
self
.
module
).
run
(
result
)
result
=
self
.
defaultTestResult
()
result
.
startTest
(
self
)
class
CythonPyregrTestCase
(
CythonRunTestCase
):
def
_run_unittest
(
self
,
result
,
*
classes
):
"""Run tests from unittest.TestCase-derived classes."""
valid_types
=
(
unittest
.
TestSuite
,
unittest
.
TestCase
)
suite
=
unittest
.
TestSuite
()
for
cls
in
classes
:
if
isinstance
(
cls
,
str
):
if
cls
in
sys
.
modules
:
suite
.
addTest
(
unittest
.
findTestCases
(
sys
.
modules
[
cls
]))
else
:
raise
ValueError
(
"str arguments must be keys in sys.modules"
)
elif
isinstance
(
cls
,
valid_types
):
suite
.
addTest
(
cls
)
else
:
suite
.
addTest
(
unittest
.
makeSuite
(
cls
))
suite
.
run
(
result
)
def
_run_doctest
(
self
,
result
,
module
):
self
.
run_doctests
(
module
,
result
)
def
run_tests
(
self
,
result
):
try
:
try
:
self
.
setUp
()
from
test
import
test_support
as
support
try
:
except
ImportError
:
# Py3k
self
.
runCompileTest
()
from
test
import
support
unittest
.
defaultTestLoader
.
loadTestsFromName
(
self
.
module
).
run
(
result
)
finally
:
def
run_unittest
(
*
classes
):
check_thread_termination
()
return
self
.
_run_unittest
(
result
,
*
classes
)
except
Exception
:
def
run_doctest
(
module
,
verbosity
=
None
):
result
.
addError
(
self
,
sys
.
exc_info
())
return
self
.
_run_doctest
(
result
,
module
)
result
.
stopTest
(
self
)
support
.
run_unittest
=
run_unittest
support
.
run_doctest
=
run_doctest
try
:
try
:
self
.
tearDown
()
module
=
__import__
(
self
.
module
)
except
Exception
:
if
hasattr
(
module
,
'test_main'
):
pass
module
.
test_main
()
except
(
unittest
.
SkipTest
,
support
.
ResourceDenied
):
result
.
addSkip
(
self
,
'ok'
)
try
:
try
:
...
...
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