diff options
author | Savannah Ostrowski <savannahostrowski@gmail.com> | 2024-10-17 09:11:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 09:11:47 (GMT) |
commit | 7b04496e5c7ed47e9653f4591674fc9ffef34587 (patch) | |
tree | f3019e1f0a4db53faeb70ac91aa0d230efb400eb /Lib/test/test_argparse.py | |
parent | 624be8699aec22bef137041478078c6fafaf032e (diff) | |
download | cpython-7b04496e5c7ed47e9653f4591674fc9ffef34587.zip cpython-7b04496e5c7ed47e9653f4591674fc9ffef34587.tar.gz cpython-7b04496e5c7ed47e9653f4591674fc9ffef34587.tar.bz2 |
gh-125542: Deprecate prefix_chars in ArgumentParser.add_argument_group() (GH-125563)
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index a3c096e..4fa6697 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -2893,6 +2893,31 @@ class TestPositionalsGroups(TestCase): result = parser.parse_args('1 2 3 4'.split()) self.assertEqual(expected, result) +class TestGroupConstructor(TestCase): + def test_group_prefix_chars(self): + parser = ErrorRaisingArgumentParser() + msg = ( + "The use of the undocumented 'prefix_chars' parameter in " + "ArgumentParser.add_argument_group() is deprecated." + ) + with self.assertWarns(DeprecationWarning) as cm: + parser.add_argument_group(prefix_chars='-+') + self.assertEqual(msg, str(cm.warning)) + self.assertEqual(cm.filename, __file__) + + def test_group_prefix_chars_default(self): + # "default" isn't quite the right word here, but it's the same as + # the parser's default prefix so it's a good test + parser = ErrorRaisingArgumentParser() + msg = ( + "The use of the undocumented 'prefix_chars' parameter in " + "ArgumentParser.add_argument_group() is deprecated." + ) + with self.assertWarns(DeprecationWarning) as cm: + parser.add_argument_group(prefix_chars='-') + self.assertEqual(msg, str(cm.warning)) + self.assertEqual(cm.filename, __file__) + # =================== # Parent parser tests # =================== |