Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.

This commit is contained in:
Florent Xicluna 2010-03-31 22:01:03 +00:00
parent ad59833649
commit 6257a7bbb2
21 changed files with 112 additions and 226 deletions

View file

@ -7,7 +7,6 @@ import sys
import textwrap
import tempfile
import unittest
import warnings
import argparse
from StringIO import StringIO
@ -4160,21 +4159,12 @@ class TestImportStar(TestCase):
self.assertTrue(hasattr(argparse, name))
def test_main():
with warnings.catch_warnings():
# silence warnings about version argument - these are expected
warnings.filterwarnings(
action='ignore',
message='The "version" argument to ArgumentParser is deprecated.',
category=DeprecationWarning)
warnings.filterwarnings(
action='ignore',
message='The format_version method is deprecated',
category=DeprecationWarning)
warnings.filterwarnings(
action='ignore',
message='The print_version method is deprecated',
category=DeprecationWarning)
# silence warnings about version argument - these are expected
with test_support.check_warnings(
('The "version" argument to ArgumentParser is deprecated.',
DeprecationWarning),
('The (format|print)_version method is deprecated',
DeprecationWarning)):
test_support.run_unittest(__name__)
# Remove global references to avoid looking like we have refleaks.
RFile.seen = {}