mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
This commit is contained in:
parent
ad59833649
commit
6257a7bbb2
21 changed files with 112 additions and 226 deletions
|
@ -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 = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue