diff options
author | Bo Bayles <bbayles@gmail.com> | 2019-05-29 08:06:12 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2019-05-29 08:06:11 (GMT) |
commit | ca804955927dddb6ae5a846dbc0248a932be9a4e (patch) | |
tree | d9cb8069d21b991842d1210e1641a95ebddde912 /Lib/test/test_shlex.py | |
parent | f83d1dbd3bfbde940117c85f5c70de00e47b7e6e (diff) | |
download | cpython-ca804955927dddb6ae5a846dbc0248a932be9a4e.zip cpython-ca804955927dddb6ae5a846dbc0248a932be9a4e.tar.gz cpython-ca804955927dddb6ae5a846dbc0248a932be9a4e.tar.bz2 |
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.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py index fd35788..a432610 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): |