order in which the tests are normally run.
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 = {}
warnings.filterwarnings("ignore",
r'complex divmod\(\), // and % are deprecated',
- DeprecationWarning)
+ DeprecationWarning,
+ r'test_coercion$')
do_infix_binops()
do_prefix_binops()
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!
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
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)
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.
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 *
'<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):
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
"""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
import warnings
warnings.filterwarnings("ignore", ".* xmllib .* obsolete.*",
- DeprecationWarning)
+ DeprecationWarning, r'xmllib$')
import test_support
import unittest