예제 #1
0
 def test_cmd_split(self):
     plain_str = ''
     unicode_str = u''
     empty_bytes = b''
     # shlex.split() can work with "plain_str" and "unicode_str" on both
     # Python 2 and Python 3.  While we're not testing Python itself,
     # this will help us catch possible differences in the Python
     # standard library should they arise.
     self.assertEqual(shlex.split(plain_str), [])
     self.assertEqual(shlex.split(astring.to_text(plain_str)), [])
     self.assertEqual(shlex.split(unicode_str), [])
     self.assertEqual(shlex.split(astring.to_text(unicode_str)), [])
     # on Python 3, shlex.split() won't work with bytes, raising:
     # AttributeError: 'bytes' object has no attribute 'read'.
     # To turn bytes into text (when necessary), that is, on
     # Python 3 only, use astring.to_text()
     self.assertEqual(shlex.split(astring.to_text(empty_bytes)), [])
     # Now let's test our specific implementation to split commands
     self.assertEqual(process.cmd_split(plain_str), [])
     self.assertEqual(process.cmd_split(unicode_str), [])
     self.assertEqual(process.cmd_split(empty_bytes), [])
     unicode_command = u"avok\xe1do_test_runner arguments"
     self.assertEqual(process.cmd_split(unicode_command),
                      [u"avok\xe1do_test_runner",
                       u"arguments"])
예제 #2
0
 def test_cmd_split(self):
     plain_str = ''
     unicode_str = u''
     empty_bytes = b''
     # shlex.split() can work with "plain_str" and "unicode_str" on both
     # Python 2 and Python 3.  While we're not testing Python itself,
     # this will help us catch possible differences in the Python
     # standard library should they arise.
     self.assertEqual(shlex.split(plain_str), [])
     self.assertEqual(shlex.split(astring.to_text(plain_str)), [])
     self.assertEqual(shlex.split(unicode_str), [])
     self.assertEqual(shlex.split(astring.to_text(unicode_str)), [])
     # on Python 3, shlex.split() won't work with bytes, raising:
     # AttributeError: 'bytes' object has no attribute 'read'.
     # To turn bytes into text (when necessary), that is, on
     # Python 3 only, use astring.to_text()
     self.assertEqual(shlex.split(astring.to_text(empty_bytes)), [])
     # Now let's test our specific implementation to split commands
     self.assertEqual(process.cmd_split(plain_str), [])
     self.assertEqual(process.cmd_split(unicode_str), [])
     self.assertEqual(process.cmd_split(empty_bytes), [])
     unicode_command = u"avok\xe1do_test_runner arguments"
     self.assertEqual(process.cmd_split(unicode_command),
                      [u"avok\xe1do_test_runner",
                       u"arguments"])
예제 #3
0
 def test_cmd_split(self):
     self.assertEqual(process.cmd_split(''), [])
     self.assertEqual(process.cmd_split("avok\xe1do_test_runner arguments"),
                      ["avok\xe1do_test_runner", "arguments"])