Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
32b7489c
Commit
32b7489c
authored
Mar 21, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just import sys at the top instead of inside lots of functions.
Add some helpers for supporting PyUNIT-based unit testing.
parent
630bdda6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
3 deletions
+35
-3
Lib/test/test_support.py
Lib/test/test_support.py
+35
-3
No files found.
Lib/test/test_support.py
View file @
32b7489c
"""Supporting definitions for the Python regression test."""
import
sys
class
Error
(
Exception
):
"""Base class for regression test exceptions."""
...
...
@@ -21,7 +23,6 @@ verbose = 1 # Flag set to 0 by regrtest.py
use_large_resources
=
1
# Flag set to 0 by regrtest.py
def
unload
(
name
):
import
sys
try
:
del
sys
.
modules
[
name
]
except
KeyError
:
...
...
@@ -29,7 +30,7 @@ def unload(name):
def
forget
(
modname
):
unload
(
modname
)
import
sys
,
os
import
os
for
dirname
in
sys
.
path
:
try
:
os
.
unlink
(
os
.
path
.
join
(
dirname
,
modname
+
'.pyc'
))
...
...
@@ -68,7 +69,6 @@ def findfile(file, here=__file__):
import
os
if
os
.
path
.
isabs
(
file
):
return
file
import
sys
path
=
sys
.
path
path
=
[
os
.
path
.
dirname
(
here
)]
+
path
for
dn
in
path
:
...
...
@@ -93,3 +93,35 @@ def check_syntax(statement):
pass
else
:
print
'Missing SyntaxError: "%s"'
%
statement
#=======================================================================
# Preliminary PyUNIT integration.
import
unittest
class
BasicTestRunner
(
unittest
.
VerboseTextTestRunner
):
def
__init__
(
self
,
stream
=
sys
.
stderr
):
unittest
.
VerboseTextTestRunner
.
__init__
(
self
,
stream
,
descriptions
=
0
)
def
run
(
self
,
test
):
result
=
unittest
.
_VerboseTextTestResult
(
self
.
stream
,
descriptions
=
0
)
test
(
result
)
return
result
def
run_unittest
(
testclass
):
"""Run tests from a unittest.TestCase-derived class."""
if
verbose
:
f
=
sys
.
stdout
else
:
import
StringIO
f
=
StringIO
.
StringIO
()
suite
=
unittest
.
makeSuite
(
testclass
)
result
=
BasicTestRunner
(
stream
=
f
).
run
(
suite
)
if
result
.
errors
or
result
.
failures
:
raise
TestFailed
(
"errors occurred in %s.%s"
%
(
testclass
.
__module__
,
testclass
.
__name__
))
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