Adjust test case formatting

This commit is contained in:
Florian Bruhin 2014-11-05 07:46:28 +01:00
parent ac355b1c7c
commit e68c28ebfc

View File

@ -28,76 +28,76 @@ from qutebrowser.utils import split
# The original test data set was from shellwords, by Hartmut Goebel. # 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/
one 'two three' four|one|two three|four| one 'two three' four/one|two three|four/
one "two\" three" four|one|two" three|four| one "two\" three" four/one|two" three|four/
one 'two'\'' three' four|one|two' three|four| one 'two'\'' three' four/one|two' three|four/
one "two three|one|two three| 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/foo|bar/
foo bar |foo|bar| foo bar /foo|bar/
foo bar bla fasel|foo|bar|bla|fasel| foo bar bla fasel/foo|bar|bla|fasel/
x y z xxxx|x|y|z|xxxx| x y z xxxx/x|y|z|xxxx/
\x bar|x|bar| \x bar/x|bar/
\ x bar| x|bar| \ x bar/ x|bar/
\ bar| bar| \ bar/ bar/
foo \x bar|foo|x|bar| foo \x bar/foo|x|bar/
foo \ x bar|foo| x|bar| foo \ x bar/foo| x|bar/
foo \ bar|foo| 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/
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/
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"|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\\\ 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\x bar\" dfadf"|foo\x bar" dfadf| "foo\x bar\" dfadf"/foo\x bar" dfadf/
\'|'| \'/'/
'foo\ bar'|foo\ bar| 'foo\ bar'/foo\ bar/
'foo\\ bar'|foo\\ bar| 'foo\\ bar'/foo\\ bar/
"foo\\\x bar\" df'a\ 'df"|foo\\x bar" df'a\ 'df| "foo\\\x bar\" df'a\ 'df"/foo\\x bar" df'a\ 'df/
\"foo|"foo| \"foo/"foo/
\"foo\x|"foox| \"foo\x/"foox/
"foo\x"|foo\x| "foo\x"/foo\x/
"foo\ "|foo\ | "foo\ "/foo\ /
foo\ xx|foo xx| foo\ xx/foo xx/
foo\ x\x|foo xx| foo\ x\x/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\\"|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\\"\'"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"/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\ 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'/foo\\ bar/
foo\ bar|foo bar| foo\ bar/foo bar/
foo#bar\nbaz|foo#bar|baz| foo#bar\nbaz/foo#bar|baz/
:-) ;-)|:-)|;-)| :-) ;-)/:-)|;-)/
áéíóú|áéíóú| áéíóú/áéíóú/
""" """
class SplitTests(unittest.TestCase): class SplitTests(unittest.TestCase):
@ -107,16 +107,16 @@ class SplitTests(unittest.TestCase):
def test_split(self): def test_split(self):
"""Test splitting.""" """Test splitting."""
for case in test_data.strip().splitlines(): for case in test_data.strip().splitlines():
cmd, *out = case.split('|')[:-1] cmd, out = case.split('/')[:-1]
cmd = cmd.replace(r'\n', '\n') cmd = cmd.replace(r'\n', '\n')
with self.subTest(cmd=cmd): with self.subTest(cmd=cmd):
items = split.split(cmd) items = split.split(cmd)
self.assertEqual(items, out) self.assertEqual(items, out.split('|'))
def test_split_keep(self): def test_split_keep(self):
"""Test splitting with keep=True.""" """Test splitting with keep=True."""
for case in test_data.strip().splitlines(): for case in test_data.strip().splitlines():
cmd, *_out = case.split('|')[:-1] cmd, _out = case.split('/')[:-1]
cmd = cmd.replace(r'\n', '\n') cmd = cmd.replace(r'\n', '\n')
with self.subTest(cmd=cmd): with self.subTest(cmd=cmd):
items = split.split(cmd, keep=True) items = split.split(cmd, keep=True)