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 sys
import warnings import warnings
warnings.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning) warnings.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning,
warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning) r'pre$')
warnings.filterwarnings("ignore", ".* statcache .*", DeprecationWarning) warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
r'^regsub$')
warnings.filterwarnings("ignore", ".* statcache .*", DeprecationWarning,
r'statcache$')
def check_all(modname): def check_all(modname):
names = {} names = {}

View file

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

View file

@ -5,8 +5,6 @@ from types import ClassType
import warnings import warnings
import sys, traceback import sys, traceback
warnings.filterwarnings("error", "", OverflowWarning, __name__)
print '5. Built-in exceptions' print '5. Built-in exceptions'
# XXX This is not really enough, each *operation* should be tested! # XXX This is not really enough, each *operation* should be tested!
@ -86,6 +84,12 @@ try: x = undefined_variable
except NameError: pass except NameError: pass
r(OverflowError) 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 x = 1
try: try:
while 1: x = x+x while 1: x = x+x

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,12 @@
"""Do a minimal test of all the modules that aren't otherwise tested.""" """Do a minimal test of all the modules that aren't otherwise tested."""
import warnings 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 from test_support import verbose

View file

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