summaryrefslogtreecommitdiff
path: root/Lib/test/test_shlex.py
diff options
context:
space:
mode:
authorBo Bayles <bbayles@gmail.com>2019-05-29 03:06:12 -0500
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2019-05-29 09:06:11 +0100
commitca804955927dddb6ae5a846dbc0248a932be9a4e (patch)
treed9cb8069d21b991842d1210e1641a95ebddde912 /Lib/test/test_shlex.py
parentf83d1dbd3bfbde940117c85f5c70de00e47b7e6e (diff)
downloadcpython-git-ca804955927dddb6ae5a846dbc0248a932be9a4e.tar.gz
bpo-22454: Add shlex.join() (the opposite of shlex.split()) (GH-7605)
Diffstat (limited to 'Lib/test/test_shlex.py')
-rw-r--r--Lib/test/test_shlex.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py
index fd35788e81..a432610d3a 100644
--- a/Lib/test/test_shlex.py
+++ b/Lib/test/test_shlex.py
@@ -308,6 +308,26 @@ class ShlexTest(unittest.TestCase):
self.assertEqual(shlex.quote("test%s'name'" % u),
"'test%s'\"'\"'name'\"'\"''" % u)
+ def testJoin(self):
+ for split_command, command in [
+ (['a ', 'b'], "'a ' b"),
+ (['a', ' b'], "a ' b'"),
+ (['a', ' ', 'b'], "a ' ' b"),
+ (['"a', 'b"'], '\'"a\' \'b"\''),
+ ]:
+ with self.subTest(command=command):
+ joined = shlex.join(split_command)
+ self.assertEqual(joined, command)
+
+ def testJoinRoundtrip(self):
+ all_data = self.data + self.posix_data
+ for command, *split_command in all_data:
+ with self.subTest(command=command):
+ joined = shlex.join(split_command)
+ resplit = shlex.split(joined)
+ self.assertEqual(split_command, resplit)
+
+
# Allow this test to be used with old shlex.py
if not getattr(shlex, "split", None):
for methname in dir(ShlexTest):