From 38108c68a210aa66789c1dcda5067a41282a5fcb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Sep 2014 16:14:31 +0200 Subject: [PATCH] Add tests for single quote with safe_shlex_split. --- qutebrowser/test/utils/test_utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qutebrowser/test/utils/test_utils.py b/qutebrowser/test/utils/test_utils.py index 38ad74468..b16dfeb0d 100644 --- a/qutebrowser/test/utils/test_utils.py +++ b/qutebrowser/test/utils/test_utils.py @@ -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\\')