remove test_support.TestSkipped and just use unittest.SkipTest

This commit is contained in:
Benjamin Peterson 2009-03-26 20:48:25 +00:00
parent 21f6aac633
commit 888a39b54c
44 changed files with 99 additions and 108 deletions

View file

@ -132,6 +132,7 @@ import sys
import time import time
import traceback import traceback
import warnings import warnings
import unittest
# I see no other way to suppress these warnings; # I see no other way to suppress these warnings;
# putting them in test_grammar.py has no effect: # putting them in test_grammar.py has no effect:
@ -567,7 +568,7 @@ def runtest_inner(test, verbose, quiet, test_times,
print test, "skipped --", msg print test, "skipped --", msg
sys.stdout.flush() sys.stdout.flush()
return -2 return -2
except (ImportError, test_support.TestSkipped), msg: except (ImportError, unittest.SkipTest), msg:
if not quiet: if not quiet:
print test, "skipped --", msg print test, "skipped --", msg
sys.stdout.flush() sys.stdout.flush()

View file

@ -1,4 +1,4 @@
from test.test_support import verbose, TestSkipped, run_unittest from test.test_support import verbose, SkipTest, run_unittest
from _locale import (setlocale, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo, from _locale import (setlocale, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo,
localeconv, Error) localeconv, Error)
import unittest import unittest
@ -7,7 +7,7 @@ from platform import uname
if uname()[0] == "Darwin": if uname()[0] == "Darwin":
maj, min, mic = [int(part) for part in uname()[2].split(".")] maj, min, mic = [int(part) for part in uname()[2].split(".")]
if (maj, min, mic) < (8, 0, 0): if (maj, min, mic) < (8, 0, 0):
raise TestSkipped("locale support broken for OS X < 10.4") raise SkipTest("locale support broken for OS X < 10.4")
candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT', candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT',
'et_EE', 'es_PY', 'no_NO', 'nl_NL', 'lv_LV', 'el_GR', 'be_BY', 'fr_BE', 'et_EE', 'es_PY', 'no_NO', 'nl_NL', 'lv_LV', 'el_GR', 'be_BY', 'fr_BE',

View file

@ -9,7 +9,7 @@ import warnings
warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated", warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated",
DeprecationWarning) DeprecationWarning)
from test.test_support import TestSkipped, run_unittest, reap_children from test.test_support import SkipTest, run_unittest, reap_children
from commands import * from commands import *
# The module says: # The module says:
@ -19,7 +19,7 @@ from commands import *
# I'll take the comment as given, and skip this suite. # I'll take the comment as given, and skip this suite.
if os.name != 'posix': if os.name != 'posix':
raise TestSkipped('Not posix; skipping test_commands') raise SkipTest('Not posix; skipping test_commands')
class CommandTests(unittest.TestCase): class CommandTests(unittest.TestCase):

View file

@ -16,16 +16,16 @@ import curses.panel
# 'curses' resource be given on the regrtest command line using the -u # 'curses' resource be given on the regrtest command line using the -u
# option. If not available, nothing after this line will be executed. # option. If not available, nothing after this line will be executed.
from test.test_support import requires, TestSkipped from test.test_support import requires, SkipTest
requires('curses') requires('curses')
# XXX: if newterm was supported we could use it instead of initscr and not exit # XXX: if newterm was supported we could use it instead of initscr and not exit
term = os.environ.get('TERM') term = os.environ.get('TERM')
if not term or term == 'unknown': if not term or term == 'unknown':
raise TestSkipped, "$TERM=%r, calling initscr() may cause exit" % term raise SkipTest, "$TERM=%r, calling initscr() may cause exit" % term
if sys.platform == "cygwin": if sys.platform == "cygwin":
raise TestSkipped("cygwin's curses mostly just hangs") raise SkipTest("cygwin's curses mostly just hangs")
def window_funcs(stdscr): def window_funcs(stdscr):
"Test the methods of windows" "Test the methods of windows"

View file

@ -31,7 +31,7 @@ import pickle, copy
import unittest import unittest
from decimal import * from decimal import *
import numbers import numbers
from test.test_support import (TestSkipped, run_unittest, run_doctest, from test.test_support import (SkipTest, run_unittest, run_doctest,
is_resource_enabled) is_resource_enabled)
import random import random
try: try:
@ -194,7 +194,7 @@ class DecimalTest(unittest.TestCase):
def eval_file(self, file): def eval_file(self, file):
global skip_expected global skip_expected
if skip_expected: if skip_expected:
raise TestSkipped raise SkipTest
return return
for line in open(file).xreadlines(): for line in open(file).xreadlines():
line = line.replace('\r\n', '').replace('\n', '') line = line.replace('\r\n', '').replace('\n', '')

View file

@ -2,7 +2,7 @@
"""Test dlmodule.c """Test dlmodule.c
Roger E. Masse revised strategy by Barry Warsaw Roger E. Masse revised strategy by Barry Warsaw
""" """
from test.test_support import verbose,TestSkipped, import_module from test.test_support import verbose,SkipTest, import_module
dl = import_module('dl', deprecated=True) dl = import_module('dl', deprecated=True)
sharedlibs = [ sharedlibs = [
@ -31,7 +31,7 @@ def test_main():
print 'worked!' print 'worked!'
break break
else: else:
raise TestSkipped, 'Could not open any shared libraries' raise SkipTest, 'Could not open any shared libraries'
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -31,13 +31,13 @@ import unittest
from test import test_support from test import test_support
if not hasattr(select, "epoll"): if not hasattr(select, "epoll"):
raise test_support.TestSkipped("test works only on Linux 2.6") raise unittest.SkipTest("test works only on Linux 2.6")
try: try:
select.epoll() select.epoll()
except IOError, e: except IOError, e:
if e.errno == errno.ENOSYS: if e.errno == errno.ENOSYS:
raise test_support.TestSkipped("kernel doesn't support epoll()") raise unittest.SkipTest("kernel doesn't support epoll()")
class TestEPoll(unittest.TestCase): class TestEPoll(unittest.TestCase):

View file

@ -4,12 +4,12 @@
import os import os
import time import time
from test.fork_wait import ForkWait from test.fork_wait import ForkWait
from test.test_support import TestSkipped, run_unittest, reap_children from test.test_support import SkipTest, run_unittest, reap_children
try: try:
os.fork os.fork
except AttributeError: except AttributeError:
raise TestSkipped, "os.fork not defined -- skipping test_fork1" raise SkipTest, "os.fork not defined -- skipping test_fork1"
class ForkTest(ForkWait): class ForkTest(ForkWait):
def wait_impl(self, cpid): def wait_impl(self, cpid):

View file

@ -3,7 +3,7 @@
taken mostly from the documentation. taken mostly from the documentation.
Roger E. Masse Roger E. Masse
""" """
from test.test_support import verbose, TestSkipped from test.test_support import verbose, SkipTest
import gl, GL, time import gl, GL, time
glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask', glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
@ -87,7 +87,7 @@ def test_main():
try: try:
display = os.environ['DISPLAY'] display = os.environ['DISPLAY']
except: except:
raise TestSkipped, "No $DISPLAY -- skipping gl test" raise SkipTest, "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:

View file

@ -1,18 +1,18 @@
import unittest import unittest
from test.test_support import TestSkipped, run_unittest from test.test_support import SkipTest, run_unittest
import os, struct import os, struct
try: try:
import fcntl, termios import fcntl, termios
except ImportError: except ImportError:
raise TestSkipped("No fcntl or termios module") raise SkipTest("No fcntl or termios module")
if not hasattr(termios,'TIOCGPGRP'): if not hasattr(termios,'TIOCGPGRP'):
raise TestSkipped("termios module doesn't have TIOCGPGRP") raise SkipTest("termios module doesn't have TIOCGPGRP")
try: try:
tty = open("/dev/tty", "r") tty = open("/dev/tty", "r")
tty.close() tty.close()
except IOError: except IOError:
raise TestSkipped("Unable to open /dev/tty") raise SkipTest("Unable to open /dev/tty")
try: try:
import pty import pty
@ -41,7 +41,7 @@ class IoctlTests(unittest.TestCase):
def test_ioctl_signed_unsigned_code_param(self): def test_ioctl_signed_unsigned_code_param(self):
if not pty: if not pty:
raise TestSkipped('pty module required') raise SkipTest('pty module required')
mfd, sfd = pty.openpty() mfd, sfd = pty.openpty()
try: try:
if termios.TIOCSWINSZ < 0: if termios.TIOCSWINSZ < 0:

View file

@ -10,7 +10,7 @@ import unittest
from test import test_support from test import test_support
if not hasattr(select, "kqueue"): if not hasattr(select, "kqueue"):
raise test_support.TestSkipped("test works only on BSD") raise unittest.SkipTest("test works only on BSD")
class TestKQueue(unittest.TestCase): class TestKQueue(unittest.TestCase):
def test_create_queue(self): def test_create_queue(self):

View file

@ -6,7 +6,7 @@ import stat
import sys import sys
import unittest import unittest
from test.test_support import run_unittest, TESTFN, verbose, requires, \ from test.test_support import run_unittest, TESTFN, verbose, requires, \
TestSkipped, unlink SkipTest, unlink
try: try:
import signal import signal
@ -104,7 +104,7 @@ class TestCase(unittest.TestCase):
# this is already decided before start running the test suite # this is already decided before start running the test suite
# but we do it anyway for extra protection # but we do it anyway for extra protection
if not hasattr(f, 'truncate'): if not hasattr(f, 'truncate'):
raise TestSkipped, "open().truncate() not available on this system" raise SkipTest, "open().truncate() not available on this system"
f.seek(0, 2) f.seek(0, 2)
# else we've lost track of the true size # else we've lost track of the true size
self.assertEqual(f.tell(), size+1) self.assertEqual(f.tell(), size+1)
@ -155,7 +155,7 @@ def test_main():
except (IOError, OverflowError): except (IOError, OverflowError):
f.close() f.close()
unlink(TESTFN) unlink(TESTFN)
raise TestSkipped, "filesystem does not have largefile support" raise SkipTest, "filesystem does not have largefile support"
else: else:
f.close() f.close()
suite = unittest.TestSuite() suite = unittest.TestSuite()

View file

@ -1,7 +1,7 @@
from test import test_support from test import test_support
test_support.requires('audio') test_support.requires('audio')
from test.test_support import findfile, TestSkipped, run_unittest from test.test_support import findfile, SkipTest, run_unittest
import errno import errno
linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True) linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True)
@ -89,7 +89,7 @@ def test_main():
dsp = linuxaudiodev.open('w') dsp = linuxaudiodev.open('w')
except linuxaudiodev.error, msg: except linuxaudiodev.error, msg:
if msg.args[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY): if msg.args[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
raise TestSkipped(msg) raise SkipTest(msg)
raise raise
dsp.close() dsp.close()
run_unittest(LinuxAudioDevTests) run_unittest(LinuxAudioDevTests)

View file

@ -1,4 +1,4 @@
from test.test_support import run_unittest, verbose, TestSkipped from test.test_support import run_unittest, verbose, SkipTest
import unittest import unittest
import locale import locale
import sys import sys
@ -10,7 +10,7 @@ enUS_locale = None
def get_enUS_locale(): def get_enUS_locale():
global enUS_locale global enUS_locale
if sys.platform == 'darwin': if sys.platform == 'darwin':
raise TestSkipped("Locale support on MacOSX is minimal") raise SkipTest("Locale support on MacOSX is minimal")
if sys.platform.startswith("win"): if sys.platform.startswith("win"):
tlocs = ("En", "English") tlocs = ("En", "English")
else: else:
@ -23,7 +23,7 @@ def get_enUS_locale():
continue continue
break break
else: else:
raise TestSkipped( raise SkipTest(
"Test locale not supported (tried %s)" % (', '.join(tlocs))) "Test locale not supported (tried %s)" % (', '.join(tlocs)))
enUS_locale = tloc enUS_locale = tloc
locale.setlocale(locale.LC_NUMERIC, oldlocale) locale.setlocale(locale.LC_NUMERIC, oldlocale)
@ -355,10 +355,10 @@ def test_main():
TestCNumberFormatting, TestCNumberFormatting,
TestFrFRNumberFormatting, TestFrFRNumberFormatting,
] ]
# TestSkipped can't be raised inside unittests, handle it manually instead # SkipTest can't be raised inside unittests, handle it manually instead
try: try:
get_enUS_locale() get_enUS_locale()
except TestSkipped as e: except SkipTest as e:
if verbose: if verbose:
print "Some tests will be disabled: %s" % e print "Some tests will be disabled: %s" % e
else: else:

View file

@ -93,7 +93,7 @@ class TestMacostools(unittest.TestCase):
def test_main(): def test_main():
# Skip on wide unicode # Skip on wide unicode
if len(u'\0'.encode('unicode-internal')) == 4: if len(u'\0'.encode('unicode-internal')) == 4:
raise test_support.TestSkipped("test_macostools is broken in USC4") raise unittest.SkipTest("test_macostools is broken in USC4")
test_support.run_unittest(TestMacostools) test_support.run_unittest(TestMacostools)

View file

@ -7,7 +7,7 @@
### mhlib. It should. ### mhlib. It should.
import unittest import unittest
from test.test_support import run_unittest, TESTFN, TestSkipped, import_module from test.test_support import run_unittest, TESTFN, SkipTest, import_module
import os, StringIO import os, StringIO
import sys import sys
mhlib = import_module('mhlib', deprecated=True) mhlib = import_module('mhlib', deprecated=True)
@ -21,7 +21,7 @@ if (sys.platform.startswith("win") or sys.platform=="riscos" or
# link counts, and that causes test_listfolders() here to get back # link counts, and that causes test_listfolders() here to get back
# an empty list from its call of listallfolders(). # an empty list from its call of listallfolders().
# The other tests here pass on Windows. # The other tests here pass on Windows.
raise TestSkipped("skipped on %s -- " % sys.platform + raise SkipTest("skipped on %s -- " % sys.platform +
"too many Unix assumptions") "too many Unix assumptions")
_mhroot = TESTFN+"_MH" _mhroot = TESTFN+"_MH"

View file

@ -4,7 +4,7 @@ import os
import sys import sys
import pickle import pickle
from StringIO import StringIO from StringIO import StringIO
from test.test_support import verbose, run_unittest, TestSkipped from test.test_support import verbose, run_unittest, SkipTest
import unittest import unittest
import xml.dom import xml.dom

View file

@ -23,8 +23,8 @@ import logging
try: try:
import multiprocessing.synchronize import multiprocessing.synchronize
except ImportError, e: except ImportError, e:
from test.test_support import TestSkipped from test.test_support import SkipTest
raise TestSkipped(e) raise SkipTest(e)
import multiprocessing.dummy import multiprocessing.dummy
import multiprocessing.connection import multiprocessing.connection
@ -1812,8 +1812,8 @@ def test_main(run=None):
try: try:
lock = multiprocessing.RLock() lock = multiprocessing.RLock()
except OSError: except OSError:
from test.test_support import TestSkipped from test.test_support import SkipTest
raise TestSkipped("OSError raises on RLock creation, see issue 3111!") raise SkipTest("OSError raises on RLock creation, see issue 3111!")
if run is None: if run is None:
from test.test_support import run_unittest as run from test.test_support import run_unittest as run

View file

@ -10,7 +10,7 @@ class NisTests(unittest.TestCase):
# NIS is probably not active, so this test isn't useful # NIS is probably not active, so this test isn't useful
if test_support.verbose: if test_support.verbose:
print "Test Skipped:", msg print "Test Skipped:", msg
# Can't raise TestSkipped as regrtest only recognizes the exception # Can't raise SkipTest as regrtest only recognizes the exception
# import time. # import time.
return return
try: try:

View file

@ -1,10 +1,10 @@
# 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, unittest import os, unittest
from test.test_support import run_unittest, TestSkipped from test.test_support import run_unittest, SkipTest
if not hasattr(os, "openpty"): if not hasattr(os, "openpty"):
raise TestSkipped, "No openpty() available." raise SkipTest, "No openpty() available."
class OpenptyTest(unittest.TestCase): class OpenptyTest(unittest.TestCase):

View file

@ -1,7 +1,7 @@
from test import test_support from test import test_support
test_support.requires('audio') test_support.requires('audio')
from test.test_support import findfile, TestSkipped from test.test_support import findfile, SkipTest
import errno import errno
import ossaudiodev import ossaudiodev
@ -45,7 +45,7 @@ class OSSAudioDevTests(unittest.TestCase):
dsp = ossaudiodev.open('w') dsp = ossaudiodev.open('w')
except IOError, msg: except IOError, msg:
if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY): if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
raise TestSkipped(msg) raise SkipTest(msg)
raise raise
# at least check that these methods can be invoked # at least check that these methods can be invoked
@ -162,7 +162,7 @@ def test_main():
dsp = ossaudiodev.open('w') dsp = ossaudiodev.open('w')
except (ossaudiodev.error, IOError), msg: except (ossaudiodev.error, IOError), msg:
if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY): if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
raise TestSkipped(msg) raise SkipTest(msg)
raise raise
dsp.close() dsp.close()
test_support.run_unittest(__name__) test_support.run_unittest(__name__)

View file

@ -3,7 +3,7 @@
import sys, os, unittest import sys, os, unittest
from test import test_support from test import test_support
if not os.path.supports_unicode_filenames: if not os.path.supports_unicode_filenames:
raise test_support.TestSkipped, "test works only on NT+" raise unittest.SkipTest, "test works only on NT+"
filenames = [ filenames = [
'abc', 'abc',

View file

@ -2,10 +2,10 @@ import pipes
import os import os
import string import string
import unittest import unittest
from test.test_support import TESTFN, run_unittest, unlink, TestSkipped from test.test_support import TESTFN, run_unittest, unlink, SkipTest
if os.name != 'posix': if os.name != 'posix':
raise TestSkipped('pipes module only works on posix') raise SkipTest('pipes module only works on posix')
TESTFN2 = TESTFN + "2" TESTFN2 = TESTFN + "2"

View file

@ -1,12 +1,12 @@
# Test case for the os.poll() function # Test case for the os.poll() function
import os, select, random, unittest import os, select, random, unittest
from test.test_support import TestSkipped, TESTFN, run_unittest from test.test_support import SkipTest, TESTFN, run_unittest
try: try:
select.poll select.poll
except AttributeError: except AttributeError:
raise TestSkipped, "select.poll not defined -- skipping test_poll" raise SkipTest, "select.poll not defined -- skipping test_poll"
def find_ready_matching(ready, flag): def find_ready_matching(ready, flag):

View file

@ -12,13 +12,13 @@ import sys
import unittest import unittest
import popen2 import popen2
from test.test_support import TestSkipped, run_unittest, reap_children from test.test_support import SkipTest, run_unittest, reap_children
if sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos': if sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos':
# Locks get messed up or something. Generally we're supposed # Locks get messed up or something. Generally we're supposed
# to avoid mixing "posix" fork & exec with native threads, and # to avoid mixing "posix" fork & exec with native threads, and
# they may be right about that after all. # they may be right about that after all.
raise TestSkipped("popen2() doesn't work on " + sys.platform) raise SkipTest("popen2() doesn't work on " + sys.platform)
# if we don't have os.popen, check that # if we don't have os.popen, check that
# we have os.fork. if not, skip the test # we have os.fork. if not, skip the test

View file

@ -5,7 +5,7 @@ from test import test_support
try: try:
import posix import posix
except ImportError: except ImportError:
raise test_support.TestSkipped, "posix is not available" raise unittest.SkipTest, "posix is not available"
import time import time
import os import os
@ -242,10 +242,10 @@ class PosixTester(unittest.TestCase):
os.mkdir(base_path) os.mkdir(base_path)
os.chdir(base_path) os.chdir(base_path)
except: except:
# Just returning nothing instead of the TestSkipped exception, # Just returning nothing instead of the SkipTest exception,
# because the test results in Error in that case. # because the test results in Error in that case.
# Is that ok? # Is that ok?
# raise test_support.TestSkipped, "cannot create directory for testing" # raise unittest.SkipTest, "cannot create directory for testing"
return return
try: try:
@ -253,7 +253,7 @@ class PosixTester(unittest.TestCase):
try: try:
os.mkdir(dirname) os.mkdir(dirname)
except: except:
raise test_support.TestSkipped, "mkdir cannot create directory sufficiently deep for getcwd test" raise unittest.SkipTest, "mkdir cannot create directory sufficiently deep for getcwd test"
os.chdir(dirname) os.chdir(dirname)
try: try:

View file

@ -4,7 +4,7 @@ import pty
import os import os
import sys import sys
import signal import signal
from test.test_support import verbose, TestSkipped, run_unittest from test.test_support import verbose, SkipTest, run_unittest
import unittest import unittest
TEST_STRING_1 = "I wish to buy a fish license.\n" TEST_STRING_1 = "I wish to buy a fish license.\n"
@ -69,7 +69,7 @@ class PtyTest(unittest.TestCase):
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 TestSkipped, "Pseudo-terminals (seemingly) not functional." raise SkipTest, "Pseudo-terminals (seemingly) not functional."
self.assertTrue(os.isatty(slave_fd), 'slave_fd is not a tty') self.assertTrue(os.isatty(slave_fd), 'slave_fd is not a tty')

View file

@ -1,13 +1,13 @@
import unittest import unittest
import sys import sys
from test.test_support import (check_warnings, CleanImport, from test.test_support import (check_warnings, CleanImport,
TestSkipped, run_unittest) SkipTest, run_unittest)
import warnings import warnings
from contextlib import nested from contextlib import nested
if not sys.py3kwarning: if not sys.py3kwarning:
raise TestSkipped('%s must be run with the -3 flag' % __name__) raise SkipTest('%s must be run with the -3 flag' % __name__)
def reset_module_registry(module): def reset_module_registry(module):
try: try:

View file

@ -10,7 +10,7 @@ import traceback
import sys, os, time, errno import sys, os, time, errno
if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos': if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos':
raise test_support.TestSkipped("Can't test signal on %s" % \ raise unittest.SkipTest("Can't test signal on %s" % \
sys.platform) sys.platform)

View file

@ -5,7 +5,7 @@ executing have not been removed.
""" """
import unittest import unittest
from test.test_support import TestSkipped, run_unittest, TESTFN from test.test_support import SkipTest, run_unittest, TESTFN
import __builtin__ import __builtin__
import os import os
import sys import sys
@ -17,7 +17,7 @@ import subprocess
if "site" in sys.modules: if "site" in sys.modules:
import site import site
else: else:
raise TestSkipped("importation of site.py suppressed") raise SkipTest("importation of site.py suppressed")
if not os.path.isdir(site.USER_SITE): if not os.path.isdir(site.USER_SITE):
# need to add user site directory for tests # need to add user site directory for tests

View file

@ -16,7 +16,7 @@ import unittest
import SocketServer import SocketServer
import test.test_support import test.test_support
from test.test_support import reap_children, verbose, TestSkipped from test.test_support import reap_children, verbose, SkipTest
from test.test_support import TESTFN as TEST_FILE from test.test_support import TESTFN as TEST_FILE
test.test_support.requires("network") test.test_support.requires("network")
@ -247,7 +247,7 @@ class SocketServerTest(unittest.TestCase):
def test_main(): def test_main():
if imp.lock_held(): if imp.lock_held():
# If the import lock is held, the threads will hang # If the import lock is held, the threads will hang
raise TestSkipped("can't run when import lock is held") raise SkipTest("can't run when import lock is held")
test.test_support.run_unittest(SocketServerTest) test.test_support.run_unittest(SocketServerTest)

View file

@ -1,9 +1,9 @@
from test.test_support import run_unittest, TestSkipped from test.test_support import run_unittest, SkipTest
try: try:
import _sqlite3 import _sqlite3
except ImportError: except ImportError:
raise TestSkipped('no sqlite available') raise SkipTest('no sqlite available')
from sqlite3.test import (dbapi, types, userfunctions, py25tests, from sqlite3.test import (dbapi, types, userfunctions, py25tests,
factory, transactions, hooks, regression, factory, transactions, hooks, regression,
dump) dump)

View file

@ -1167,7 +1167,7 @@ else:
def test_main(verbose=False): def test_main(verbose=False):
if skip_expected: if skip_expected:
raise test_support.TestSkipped("No SSL support") raise unittest.SkipTest("No SSL support")
global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,

View file

@ -1,4 +1,4 @@
from test.test_support import findfile, TestFailed, TestSkipped, import_module from test.test_support import findfile, TestFailed, SkipTest, import_module
sunaudiodev = import_module('sunaudiodev', deprecated=True) sunaudiodev = import_module('sunaudiodev', deprecated=True)
import os import os
@ -8,7 +8,7 @@ except KeyError:
audiodev = "/dev/audio" audiodev = "/dev/audio"
if not os.path.exists(audiodev): if not os.path.exists(audiodev):
raise TestSkipped("no audio device found!") raise SkipTest("no audio device found!")
def play_sound_file(path): def play_sound_file(path):
fp = open(path, 'r') fp = open(path, 'r')

View file

@ -13,7 +13,7 @@ import shutil
import warnings import warnings
import unittest import unittest
__all__ = ["Error", "TestFailed", "TestSkipped", "ResourceDenied", "import_module", __all__ = ["Error", "TestFailed", "ResourceDenied", "import_module",
"verbose", "use_resources", "max_memuse", "record_original_stdout", "verbose", "use_resources", "max_memuse", "record_original_stdout",
"get_original_stdout", "unload", "unlink", "rmtree", "forget", "get_original_stdout", "unload", "unlink", "rmtree", "forget",
"is_resource_enabled", "requires", "find_unused_port", "bind_port", "is_resource_enabled", "requires", "find_unused_port", "bind_port",
@ -33,17 +33,7 @@ class Error(Exception):
class TestFailed(Error): class TestFailed(Error):
"""Test failed.""" """Test failed."""
class TestSkipped(Error): class ResourceDenied(SkipTest):
"""Test skipped.
This can be raised to indicate that a test was deliberatly
skipped, but not because a feature wasn't available. For
example, if some resource can't be used, such as the network
appears to be unavailable, this should be raised instead of
TestFailed.
"""
class ResourceDenied(TestSkipped):
"""Test skipped because it requested a disallowed resource. """Test skipped because it requested a disallowed resource.
This is raised when a test calls requires() for a resource that This is raised when a test calls requires() for a resource that
@ -52,7 +42,7 @@ class ResourceDenied(TestSkipped):
""" """
def import_module(name, deprecated=False): def import_module(name, deprecated=False):
"""Import the module to be tested, raising TestSkipped if it is not """Import the module to be tested, raising SkipTest if it is not
available.""" available."""
with warnings.catch_warnings(): with warnings.catch_warnings():
if deprecated: if deprecated:
@ -61,7 +51,7 @@ def import_module(name, deprecated=False):
try: try:
module = __import__(name, level=0) module = __import__(name, level=0)
except ImportError: except ImportError:
raise TestSkipped("No module named " + name) raise SkipTest("No module named " + name)
else: else:
return module return module

View file

@ -259,7 +259,7 @@ class test__mkstemp_inner(TC):
def test_file_mode(self): def test_file_mode(self):
# _mkstemp_inner creates files with the proper mode # _mkstemp_inner creates files with the proper mode
if not has_stat: if not has_stat:
return # ugh, can't use TestSkipped. return # ugh, can't use SkipTest.
file = self.do_create() file = self.do_create()
mode = stat.S_IMODE(os.stat(file.name).st_mode) mode = stat.S_IMODE(os.stat(file.name).st_mode)
@ -274,7 +274,7 @@ class test__mkstemp_inner(TC):
def test_noinherit(self): def test_noinherit(self):
# _mkstemp_inner file handles are not inherited by child processes # _mkstemp_inner file handles are not inherited by child processes
if not has_spawnl: if not has_spawnl:
return # ugh, can't use TestSkipped. return # ugh, can't use SkipTest.
if test_support.verbose: if test_support.verbose:
v="v" v="v"
@ -312,7 +312,7 @@ class test__mkstemp_inner(TC):
def test_textmode(self): def test_textmode(self):
# _mkstemp_inner can create files in text mode # _mkstemp_inner can create files in text mode
if not has_textmode: if not has_textmode:
return # ugh, can't use TestSkipped. return # ugh, can't use SkipTest.
self.do_create(bin=0).write("blat\n") self.do_create(bin=0).write("blat\n")
# XXX should test that the file really is a text file # XXX should test that the file really is a text file
@ -476,7 +476,7 @@ class test_mkdtemp(TC):
def test_mode(self): def test_mode(self):
# mkdtemp creates directories with the proper mode # mkdtemp creates directories with the proper mode
if not has_stat: if not has_stat:
return # ugh, can't use TestSkipped. return # ugh, can't use SkipTest.
dir = self.do_create() dir = self.do_create()
try: try:

View file

@ -6,7 +6,7 @@
# randrange, and then Python hangs. # randrange, and then Python hangs.
import thread import thread
from test.test_support import verbose, TestSkipped, TestFailed from test.test_support import verbose, SkipTest, TestFailed
critical_section = thread.allocate_lock() critical_section = thread.allocate_lock()
done = thread.allocate_lock() done = thread.allocate_lock()
@ -56,7 +56,7 @@ def test_main(): # magic name! see above
import imp import imp
if imp.lock_held(): if imp.lock_held():
# This triggers on, e.g., from test import autotest. # This triggers on, e.g., from test import autotest.
raise TestSkipped("can't run when import lock is held") raise SkipTest("can't run when import lock is held")
done.acquire() done.acquire()
for N in (20, 50) * 3: for N in (20, 50) * 3:

View file

@ -5,10 +5,10 @@ import thread
import signal import signal
import os import os
import sys import sys
from test.test_support import run_unittest, TestSkipped from test.test_support import run_unittest, SkipTest
if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
raise TestSkipped, "Can't test signal on %s" % sys.platform raise SkipTest, "Can't test signal on %s" % sys.platform
process_pid = os.getpid() process_pid = os.getpid()
signalled_all=thread.allocate_lock() signalled_all=thread.allocate_lock()

View file

@ -7,7 +7,7 @@ try:
Tkinter.Button() Tkinter.Button()
except Tkinter.TclError, msg: except Tkinter.TclError, msg:
# assuming tk is not available # assuming tk is not available
raise test_support.TestSkipped("tk not available: %s" % msg) raise unittest.SkipTest("tk not available: %s" % msg)
this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(os.path.abspath(__file__))
lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,

View file

@ -8,7 +8,7 @@ try:
ttk.Button() ttk.Button()
except TclError, msg: except TclError, msg:
# assuming ttk is not available # assuming ttk is not available
raise test_support.TestSkipped("ttk not available: %s" % msg) raise unittest.SkipTest("ttk not available: %s" % msg)
this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(os.path.abspath(__file__))
lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,

View file

@ -5,14 +5,14 @@ import os, glob, time, shutil
import unicodedata import unicodedata
import unittest import unittest
from test.test_support import run_unittest, TestSkipped, TESTFN_UNICODE from test.test_support import run_unittest, SkipTest, TESTFN_UNICODE
from test.test_support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE from test.test_support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE
try: try:
TESTFN_ENCODED = TESTFN_UNICODE.encode(TESTFN_ENCODING) TESTFN_ENCODED = TESTFN_UNICODE.encode(TESTFN_ENCODING)
except (UnicodeError, TypeError): except (UnicodeError, TypeError):
# Either the file system encoding is None, or the file name # Either the file system encoding is None, or the file name
# cannot be encoded in the file system encoding. # cannot be encoded in the file system encoding.
raise TestSkipped("No Unicode filesystem semantics on this platform.") raise SkipTest("No Unicode filesystem semantics on this platform.")
if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE: if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
# The file system encoding does not support Latin-1 # The file system encoding does not support Latin-1
@ -26,10 +26,10 @@ if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
# MBCS will not report the error properly # MBCS will not report the error properly
raise UnicodeError, "mbcs encoding problem" raise UnicodeError, "mbcs encoding problem"
except (UnicodeError, TypeError): except (UnicodeError, TypeError):
raise TestSkipped("Cannot find a suiteable filename.") raise SkipTest("Cannot find a suiteable filename.")
if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE: if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
raise TestSkipped("Cannot find a suitable filename.") raise SkipTest("Cannot find a suitable filename.")
def remove_if_exists(filename): def remove_if_exists(filename):
if os.path.exists(filename): if os.path.exists(filename):

View file

@ -5,7 +5,7 @@ import sys
from test import test_support from test import test_support
if not hasattr(sys.stdin, 'newlines'): if not hasattr(sys.stdin, 'newlines'):
raise test_support.TestSkipped, \ raise unittest.SkipTest, \
"This Python does not have universal newline support" "This Python does not have universal newline support"
FATX = 'x' * (2**14) FATX = 'x' * (2**14)

View file

@ -4,17 +4,17 @@
import os import os
import time import time
from test.fork_wait import ForkWait from test.fork_wait import ForkWait
from test.test_support import TestSkipped, run_unittest, reap_children from test.test_support import SkipTest, run_unittest, reap_children
try: try:
os.fork os.fork
except AttributeError: except AttributeError:
raise TestSkipped, "os.fork not defined -- skipping test_wait3" raise SkipTest, "os.fork not defined -- skipping test_wait3"
try: try:
os.wait3 os.wait3
except AttributeError: except AttributeError:
raise TestSkipped, "os.wait3 not defined -- skipping test_wait3" raise SkipTest, "os.wait3 not defined -- skipping test_wait3"
class Wait3Test(ForkWait): class Wait3Test(ForkWait):
def wait_impl(self, cpid): def wait_impl(self, cpid):

View file

@ -4,17 +4,17 @@
import os import os
import time import time
from test.fork_wait import ForkWait from test.fork_wait import ForkWait
from test.test_support import TestSkipped, run_unittest, reap_children from test.test_support import SkipTest, run_unittest, reap_children
try: try:
os.fork os.fork
except AttributeError: except AttributeError:
raise TestSkipped, "os.fork not defined -- skipping test_wait4" raise SkipTest, "os.fork not defined -- skipping test_wait4"
try: try:
os.wait4 os.wait4
except AttributeError: except AttributeError:
raise TestSkipped, "os.wait4 not defined -- skipping test_wait4" raise SkipTest, "os.wait4 not defined -- skipping test_wait4"
class Wait4Test(ForkWait): class Wait4Test(ForkWait):
def wait_impl(self, cpid): def wait_impl(self, cpid):