Tighten up some warning filters, and break some dependencies on the

order in which the tests are normally run.
This commit is contained in:
Tim Peters 2002-04-16 01:27:44 +00:00
parent 50ac30ee01
commit d392506c43
9 changed files with 34 additions and 16 deletions

View file

@ -2,9 +2,12 @@ from test_support import verify, verbose
import sys
import warnings
warnings.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning)
warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning)
warnings.filterwarnings("ignore", ".* statcache .*", DeprecationWarning)
warnings.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning,
r'pre$')
warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
r'^regsub$')
warnings.filterwarnings("ignore", ".* statcache .*", DeprecationWarning,
r'statcache$')
def check_all(modname):
names = {}

View file

@ -112,6 +112,7 @@ def do_prefix_binops():
warnings.filterwarnings("ignore",
r'complex divmod\(\), // and % are deprecated',
DeprecationWarning)
DeprecationWarning,
r'test_coercion$')
do_infix_binops()
do_prefix_binops()

View file

@ -5,8 +5,6 @@ from types import ClassType
import warnings
import sys, traceback
warnings.filterwarnings("error", "", OverflowWarning, __name__)
print '5. Built-in exceptions'
# XXX This is not really enough, each *operation* should be tested!
@ -86,6 +84,12 @@ try: x = undefined_variable
except NameError: pass
r(OverflowError)
# XXX
# Obscure: this test relies on int+int raising OverflowError if the
# ints are big enough. But ints no longer do that by default. This
# test will have to go away someday. For now, we can convert the
# transitional OverflowWarning into an error.
warnings.filterwarnings("error", "", OverflowWarning, __name__)
x = 1
try:
while 1: x = x+x

View file

@ -33,7 +33,7 @@ class TemporaryFileTests(unittest.TestCase):
if not hasattr(os, "tempnam"):
return
warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
"test_os")
r"test_os$")
self.check_tempfile(os.tempnam())
name = os.tempnam(TESTFN)
@ -57,7 +57,7 @@ class TemporaryFileTests(unittest.TestCase):
if not hasattr(os, "tmpnam"):
return
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
"test_os")
r"test_os$")
self.check_tempfile(os.tmpnam())
# Test attributes on return values from os.*stat* family.

View file

@ -1,7 +1,7 @@
from test_support import verbose, sortdict
import warnings
warnings.filterwarnings("ignore", "the regex module is deprecated",
DeprecationWarning, __name__)
DeprecationWarning, r'test_regex$')
import regex
from regex_syntax import *

View file

@ -105,14 +105,18 @@ class ReprTests(unittest.TestCase):
'<built-in method split of str object at 0x'))
def test_xrange(self):
import warnings
eq = self.assertEquals
eq(repr(xrange(1)), 'xrange(1)')
eq(repr(xrange(1, 2)), 'xrange(1, 2)')
eq(repr(xrange(1, 2, 3)), 'xrange(1, 4, 3)')
# Turn off warnings for deprecated multiplication
import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning,
module=ReprTests.__module__)
warnings.filterwarnings('ignore',
r'xrange object multiplication is deprecated',
DeprecationWarning, module=ReprTests.__module__)
warnings.filterwarnings('ignore',
r"PyRange_New's 'repetitions' argument is deprecated",
DeprecationWarning, module=ReprTests.__module__)
eq(repr(xrange(1) * 3), '(xrange(1) * 3)')
def test_nesting(self):

View file

@ -1,6 +1,7 @@
import warnings
warnings.filterwarnings("ignore", "", DeprecationWarning, __name__)
warnings.filterwarnings("ignore", "", DeprecationWarning, "unittest")
warnings.filterwarnings("ignore", "strop functions are obsolete;",
DeprecationWarning,
r'test_strop|unittest')
import strop
import test_support
import unittest

View file

@ -1,7 +1,12 @@
"""Do a minimal test of all the modules that aren't otherwise tested."""
import warnings
warnings.filterwarnings('ignore', '', DeprecationWarning, 'posixfile')
warnings.filterwarnings('ignore', r".*posixfile module",
DeprecationWarning, 'posixfile$')
warnings.filterwarnings('ignore', r".*statcache module",
DeprecationWarning, 'statcache$')
warnings.filterwarnings('ignore', r".*'re' module",
DeprecationWarning, 'pre$')
from test_support import verbose

View file

@ -15,7 +15,7 @@ testdoc = """\
import warnings
warnings.filterwarnings("ignore", ".* xmllib .* obsolete.*",
DeprecationWarning)
DeprecationWarning, r'xmllib$')
import test_support
import unittest