summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-07-29 20:51:47 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-07-29 20:51:47 (GMT)
commit76b1714be84ab6e73b9b0716cbb233f044318516 (patch)
tree08a691da7726a3039f641197a4b190c73018633f /Lib/test/test_argparse.py
parentada5578f95bcd4b402e0e3111bb65cb70ee0daae (diff)
downloadcpython-76b1714be84ab6e73b9b0716cbb233f044318516.zip
cpython-76b1714be84ab6e73b9b0716cbb233f044318516.tar.gz
cpython-76b1714be84ab6e73b9b0716cbb233f044318516.tar.bz2
Issue #24360: Improve __repr__ of argparse.Namespace() for invalid identifiers.
Patch by Matthias Bussonnier.
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 27bfad5..893ec39 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -4512,6 +4512,21 @@ class TestStrings(TestCase):
string = "Namespace(bar='spam', foo=42)"
self.assertStringEqual(ns, string)
+ def test_namespace_starkwargs_notidentifier(self):
+ ns = argparse.Namespace(**{'"': 'quote'})
+ string = """Namespace(**{'"': 'quote'})"""
+ self.assertStringEqual(ns, string)
+
+ def test_namespace_kwargs_and_starkwargs_notidentifier(self):
+ ns = argparse.Namespace(a=1, **{'"': 'quote'})
+ string = """Namespace(a=1, **{'"': 'quote'})"""
+ self.assertStringEqual(ns, string)
+
+ def test_namespace_starkwargs_identifier(self):
+ ns = argparse.Namespace(**{'valid': True})
+ string = "Namespace(valid=True)"
+ self.assertStringEqual(ns, string)
+
def test_parser(self):
parser = argparse.ArgumentParser(prog='PROG')
string = (