Add tests for single quote with safe_shlex_split.

This commit is contained in:
Florian Bruhin 2014-09-18 16:14:31 +02:00
parent b2340611f2
commit 38108c68a2

View File

@ -125,16 +125,31 @@ class SafeShlexSplitTests(unittest.TestCase):
items = utils.safe_shlex_split('one "two three" four')
self.assertEqual(items, ['one', 'two three', 'four'])
def test_single_quoted(self):
"""Test safe_shlex_split with a single quoted string."""
items = utils.safe_shlex_split("one 'two three' four")
self.assertEqual(items, ['one', 'two three', 'four'])
def test_escaped(self):
"""Test safe_shlex_split with a normal escaped string."""
items = utils.safe_shlex_split(r'one "two\" three" four')
self.assertEqual(items, ['one', 'two" three', 'four'])
def test_escaped_single(self):
"""Test safe_shlex_split with a single escaped string."""
items = utils.safe_shlex_split(r"one 'two\' three' four")
self.assertEqual(items, ['one', "two' three", 'four'])
def test_unbalanced_quotes(self):
"""Test safe_shlex_split with unbalanded quotes."""
items = utils.safe_shlex_split(r'one "two three')
self.assertEqual(items, ['one', 'two three'])
def test_unbalanced_single_quotes(self):
"""Test safe_shlex_split with unbalanded single quotes."""
items = utils.safe_shlex_split(r"one 'two three")
self.assertEqual(items, ['one', "two three"])
def test_unfinished_escape(self):
"""Test safe_shlex_split with an unfinished escape."""
items = utils.safe_shlex_split('one\\')