Raise 'TestSkipped' (from the test_support) module rather than 'ImportError'
to signify a test that should be marked as 'skipped' rather than 'failed'. Also 'document' it, in README.
This commit is contained in:
parent
040c17fe38
commit
b9fa0a843e
|
@ -12,7 +12,8 @@ functionality. The mechanics of how the test system operates are fairly
|
||||||
straightforward. When a test case is run, the output is compared with the
|
straightforward. When a test case is run, the output is compared with the
|
||||||
expected output that is stored in .../Lib/test/output. If the test runs to
|
expected output that is stored in .../Lib/test/output. If the test runs to
|
||||||
completion and the actual and expected outputs match, the test succeeds, if
|
completion and the actual and expected outputs match, the test succeeds, if
|
||||||
not, it fails. If an ImportError is raised, the test is not run.
|
not, it fails. If an ImportError or test_support.TestSkipped error is
|
||||||
|
raised, the test is not run.
|
||||||
|
|
||||||
You will be writing unit tests (isolated tests of functions and objects
|
You will be writing unit tests (isolated tests of functions and objects
|
||||||
defined by the module) using white box techniques. Unlike black box
|
defined by the module) using white box techniques. Unlike black box
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"""
|
"""
|
||||||
import binhex
|
import binhex
|
||||||
import tempfile
|
import tempfile
|
||||||
from test_support import verbose
|
from test_support import verbose, TestSkipped
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ def test():
|
||||||
fname2 = tempfile.mktemp()
|
fname2 = tempfile.mktemp()
|
||||||
f = open(fname1, 'w')
|
f = open(fname1, 'w')
|
||||||
except:
|
except:
|
||||||
raise ImportError, "Cannot test binhex without a temp file"
|
raise TestSkipped, "Cannot test binhex without a temp file"
|
||||||
|
|
||||||
start = 'Jack is my hero'
|
start = 'Jack is my hero'
|
||||||
f.write(start)
|
f.write(start)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import dl
|
import dl
|
||||||
from test_support import verbose
|
from test_support import verbose,TestSkipped
|
||||||
|
|
||||||
sharedlibs = [
|
sharedlibs = [
|
||||||
('/usr/lib/libc.so', 'getpid'),
|
('/usr/lib/libc.so', 'getpid'),
|
||||||
|
@ -29,4 +29,4 @@ for s, func in sharedlibs:
|
||||||
print 'worked!'
|
print 'worked!'
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise ImportError, 'Could not open any shared libraries'
|
raise TestSkipped, 'Could not open any shared libraries'
|
||||||
|
|
|
@ -9,11 +9,12 @@ active threads survive in the child after a fork(); this is an error.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, sys, time, thread
|
import os, sys, time, thread
|
||||||
|
from test_support import TestSkipped
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.fork
|
os.fork
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise ImportError, "os.fork not defined -- skipping test_fork1"
|
raise TestSkipped, "os.fork not defined -- skipping test_fork1"
|
||||||
|
|
||||||
LONGSLEEP = 2
|
LONGSLEEP = 2
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
taken mostly from the documentation.
|
taken mostly from the documentation.
|
||||||
Roger E. Masse
|
Roger E. Masse
|
||||||
"""
|
"""
|
||||||
from test_support import verbose
|
from test_support import verbose, TestSkipped
|
||||||
import gl, GL, time
|
import gl, GL, time
|
||||||
|
|
||||||
glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
|
glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
|
||||||
|
@ -87,8 +87,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
display = os.environ['DISPLAY']
|
display = os.environ['DISPLAY']
|
||||||
except:
|
except:
|
||||||
# Raise ImportError because regrtest.py handles it specially.
|
raise TestSkipped, "No $DISPLAY -- skipping gl test"
|
||||||
raise ImportError, "No $DISPLAY -- skipping gl test"
|
|
||||||
|
|
||||||
# touch all the attributes of gl without doing anything
|
# touch all the attributes of gl without doing anything
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from test_support import verbose, TestFailed
|
from test_support import verbose, TestFailed, TestSkipped
|
||||||
import nis
|
import nis
|
||||||
|
|
||||||
print 'nis.maps()'
|
print 'nis.maps()'
|
||||||
|
@ -9,7 +9,7 @@ except nis.error, msg:
|
||||||
if verbose:
|
if verbose:
|
||||||
raise TestFailed, msg
|
raise TestFailed, msg
|
||||||
# only do this if running under the regression suite
|
# only do this if running under the regression suite
|
||||||
raise ImportError, msg
|
raise TestSkipped, msg
|
||||||
|
|
||||||
done = 0
|
done = 0
|
||||||
for nismap in maps:
|
for nismap in maps:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Test to see if openpty works. (But don't worry if it isn't available.)
|
# Test to see if openpty works. (But don't worry if it isn't available.)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from test_support import verbose, TestFailed
|
from test_support import verbose, TestFailed, TestSkipped
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if verbose:
|
if verbose:
|
||||||
|
@ -10,7 +10,7 @@ try:
|
||||||
if verbose:
|
if verbose:
|
||||||
print "(master, slave) = (%d, %d)"%(master, slave)
|
print "(master, slave) = (%d, %d)"%(master, slave)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise ImportError, "No openpty() available."
|
raise TestSkipped, "No openpty() available."
|
||||||
|
|
||||||
if not os.isatty(master):
|
if not os.isatty(master):
|
||||||
raise TestFailed, "Master-end of pty is not a terminal."
|
raise TestFailed, "Master-end of pty is not a terminal."
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import pty, os, sys, string
|
import pty, os, sys, string
|
||||||
from test_support import verbose, TestFailed
|
from test_support import verbose, TestFailed, TestSkipped
|
||||||
|
|
||||||
TEST_STRING_1 = "I wish to buy a fish license."
|
TEST_STRING_1 = "I wish to buy a fish license."
|
||||||
TEST_STRING_2 = "For my pet fish, Eric."
|
TEST_STRING_2 = "For my pet fish, Eric."
|
||||||
|
@ -25,7 +25,7 @@ try:
|
||||||
debug("Got slave_fd '%d'"%slave_fd)
|
debug("Got slave_fd '%d'"%slave_fd)
|
||||||
except OSError:
|
except OSError:
|
||||||
# " An optional feature could not be imported " ... ?
|
# " An optional feature could not be imported " ... ?
|
||||||
raise ImportError, "Pseudo-terminals (seemingly) not functional."
|
raise TestSkipped, "Pseudo-terminals (seemingly) not functional."
|
||||||
|
|
||||||
if not os.isatty(master_fd):
|
if not os.isatty(master_fd):
|
||||||
raise TestFailed, "master_fd is not a tty"
|
raise TestFailed, "master_fd is not a tty"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# Test the signal module
|
# Test the signal module
|
||||||
from test_support import verbose
|
from test_support import verbose, TestSkipped
|
||||||
import signal
|
import signal
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.platform[:3] in ('win', 'os2'):
|
if sys.platform[:3] in ('win', 'os2'):
|
||||||
raise ImportError, "Can't test signal on %s" % sys.platform[:3]
|
raise TestSkipped, "Can't test signal on %s" % sys.platform[:3]
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
x = '-x'
|
x = '-x'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from test_support import verbose
|
from test_support import verbose, TestSkipped
|
||||||
import string_tests
|
import string_tests
|
||||||
import string, sys
|
import string, sys
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import string, sys
|
||||||
try:
|
try:
|
||||||
''.join
|
''.join
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise ImportError
|
raise TestSkipped
|
||||||
|
|
||||||
def test(name, input, output, *args):
|
def test(name, input, output, *args):
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|
Loading…
Reference in New Issue