From 9ed466b5368604d03afeef0646b2167976d82c5d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 4 Nov 2014 21:08:26 +0100 Subject: [PATCH] Add python shlex tests --- qutebrowser/test/utils/test_split.py | 64 ++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/qutebrowser/test/utils/test_split.py b/qutebrowser/test/utils/test_split.py index 8880e13df..39b8e004f 100644 --- a/qutebrowser/test/utils/test_split.py +++ b/qutebrowser/test/utils/test_split.py @@ -24,6 +24,9 @@ import unittest from qutebrowser.utils import split +# Most tests copied from Python's shlex. +# The original test data set was from shellwords, by Hartmut Goebel. + test_data = r""" one two|one|two| one "two three" four|one|two three|four| @@ -34,6 +37,67 @@ one "two three|one|two three| one 'two three|one|two three| one\|one\| one "two\|one|two\| +foo bar|foo|bar| + foo bar|foo|bar| + foo bar |foo|bar| +foo bar bla fasel|foo|bar|bla|fasel| +x y z xxxx|x|y|z|xxxx| +\x bar|x|bar| +\ x bar| x|bar| +\ bar| bar| +foo \x bar|foo|x|bar| +foo \ x bar|foo| x|bar| +foo \ bar|foo| bar| +foo "bar" bla|foo|bar|bla| +"foo" "bar" "bla"|foo|bar|bla| +"foo" bar "bla"|foo|bar|bla| +"foo" bar bla|foo|bar|bla| +foo 'bar' bla|foo|bar|bla| +'foo' 'bar' 'bla'|foo|bar|bla| +'foo' bar 'bla'|foo|bar|bla| +'foo' bar bla|foo|bar|bla| +blurb foo"bar"bar"fasel" baz|blurb|foobarbarfasel|baz| +blurb foo'bar'bar'fasel' baz|blurb|foobarbarfasel|baz| +""|| +''|| +foo "" bar|foo||bar| +foo '' bar|foo||bar| +foo "" "" "" bar|foo||||bar| +foo '' '' '' bar|foo||||bar| +\"|"| +"\""|"| +"foo\ bar"|foo\ bar| +"foo\\ bar"|foo\ bar| +"foo\\ bar\""|foo\ bar"| +"foo\\" bar\"|foo\|bar"| +"foo\\ bar\" dfadf"|foo\ bar" dfadf| +"foo\\\ bar\" dfadf"|foo\\ bar" dfadf| +"foo\\\x bar\" dfadf"|foo\\x bar" dfadf| +"foo\x bar\" dfadf"|foo\x bar" dfadf| +\'|'| +'foo\ bar'|foo\ bar| +'foo\\ bar'|foo\\ bar| +"foo\\\x bar\" df'a\ 'df"|foo\\x bar" df'a\ 'df| +\"foo|"foo| +\"foo\x|"foox| +"foo\x"|foo\x| +"foo\ "|foo\ | +foo\ xx|foo xx| +foo\ x\x|foo xx| +foo\ x\x\"|foo xx"| +"foo\ x\x"|foo\ x\x| +"foo\ x\x\\"|foo\ x\x\| +"foo\ x\x\\""foobar"|foo\ x\x\foobar| +"foo\ x\x\\"\'"foobar"|foo\ x\x\'foobar| +"foo\ x\x\\"\'"fo'obar"|foo\ x\x\'fo'obar| +"foo\ x\x\\"\'"fo'obar" 'don'\''t'|foo\ x\x\'fo'obar|don't| +"foo\ x\x\\"\'"fo'obar" 'don'\''t' \\|foo\ x\x\'fo'obar|don't|\| +'foo\ bar'|foo\ bar| +'foo\\ bar'|foo\\ bar| +foo\ bar|foo bar| +foo#bar\nbaz|foo#bar|baz| +:-) ;-)|:-)|;-)| +áéíóú|áéíóú| """ class SplitTests(unittest.TestCase):