diff options
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): |