diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2021-12-16 15:31:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-16 15:31:08 (GMT) |
commit | 30322c497e0b8d978f7a0de95985aac9c5daf1ac (patch) | |
tree | 4fb3f46fa7b17cdfc21157b426e5b2e2ec1443bb /Lib/test/test_argparse.py | |
parent | d6e13747161d7b634b47d2d3d212ed3be4a21fab (diff) | |
download | cpython-30322c497e0b8d978f7a0de95985aac9c5daf1ac.zip cpython-30322c497e0b8d978f7a0de95985aac9c5daf1ac.tar.gz cpython-30322c497e0b8d978f7a0de95985aac9c5daf1ac.tar.bz2 |
bpo-22047: [argparse] deprecate nested argument groups and mutually exclusive groups (GH-30098)
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index eb37d4d..4c23610 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -9,6 +9,7 @@ import textwrap import tempfile import unittest import argparse +import warnings from io import StringIO @@ -2973,15 +2974,24 @@ class TestMutuallyExclusiveOptionalsAndPositionalsMixed(MEMixin, TestCase): class TestMutuallyExclusiveNested(MEMixin, TestCase): + # Nesting mutually exclusive groups is an undocumented feature + # that came about by accident through inheritance and has been + # the source of many bugs. It is deprecated and this test should + # eventually be removed along with it. + def get_parser(self, required): parser = ErrorRaisingArgumentParser(prog='PROG') group = parser.add_mutually_exclusive_group(required=required) group.add_argument('-a') group.add_argument('-b') - group2 = group.add_mutually_exclusive_group(required=required) + with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + group2 = group.add_mutually_exclusive_group(required=required) group2.add_argument('-c') group2.add_argument('-d') - group3 = group2.add_mutually_exclusive_group(required=required) + with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + group3 = group2.add_mutually_exclusive_group(required=required) group3.add_argument('-e') group3.add_argument('-f') return parser |