From: Brett Cannon Date: Sat, 20 Mar 2010 20:59:33 +0000 (+0000) Subject: Clean up the manipulation of the warnings filter in test_builtin. X-Git-Tag: v3.2a1~1390 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=776289934c74d827290fcb0ba11dafb2e434bf4a;p=python Clean up the manipulation of the warnings filter in test_builtin. --- diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index c7e03dfa66..5df7efbe90 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -2,15 +2,11 @@ import platform import unittest -from test.support import fcmp, TESTFN, unlink, run_unittest +from test.support import fcmp, TESTFN, unlink, run_unittest, check_warnings from operator import neg import sys, warnings, random, collections, io -warnings.filterwarnings("ignore", "hex../oct.. of negative int", - FutureWarning, __name__) -warnings.filterwarnings("ignore", "integer argument expected", - DeprecationWarning, "unittest") import builtins class Squares: @@ -427,9 +423,10 @@ class BuiltinTest(unittest.TestCase): g = {} l = {} - import warnings - warnings.filterwarnings("ignore", "global statement", module="") - exec('global a; a = 1; b = 2', g, l) + with check_warnings(): + warnings.filterwarnings("ignore", "global statement", + module="") + exec('global a; a = 1; b = 2', g, l) if '__builtins__' in g: del g['__builtins__'] if '__builtins__' in l: