summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-31 22:01:03 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-31 22:01:03 (GMT)
commit6257a7bbb2660ae75c44f2e71d7ac2ce73900f74 (patch)
tree6f010065c95f2d5617f56e07ba2628be21cf9d7a /Lib/test/test_argparse.py
parentad5983364966b49c277b495112ae41c6ae2d01ed (diff)
downloadcpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.zip
cpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.tar.gz
cpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.tar.bz2
Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py22
1 files changed, 6 insertions, 16 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index efe175d..cefae25 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -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 = {}