Add python shlex tests
This commit is contained in:
parent
c308de95d1
commit
9ed466b536
@ -24,6 +24,9 @@ import unittest
|
|||||||
from qutebrowser.utils import split
|
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"""
|
test_data = r"""
|
||||||
one two|one|two|
|
one two|one|two|
|
||||||
one "two three" four|one|two three|four|
|
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 'two three|one|two three|
|
||||||
one\|one\|
|
one\|one\|
|
||||||
one "two\|one|two\|
|
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):
|
class SplitTests(unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user