Beispiel #1
0
 def test_escape(self):
     legal_path = DayuPath('/Users/andyguo/Desktop/111.mov')
     self.assertEqual(legal_path.escape(), '/Users/andyguo/Desktop/111.mov')
     whitespace_path = DayuPath(
         '/Users/andyguo/Desktop/some words with space.mov')
     self.assertEqual(
         whitespace_path.escape(),
         '/Users/andyguo/Desktop/some\ words\ with\ space.mov')
     bash_string = DayuPath('The$!cat#&ran\"\'up()a|<>tree`;')
     self.assertEqual(bash_string.escape(),
                      r'The\$\!cat\#\&ran\"\'up\(\)a\|\<\>tree\`\;')
     unicode_string = DayuPath(
         u'/Users/andyguo/Desktop/中文 和 空格12234 rer.jpg')
     self.assertEqual(unicode_string.escape(),
                      u'/Users/andyguo/Desktop/中文\ 和\ 空格12234\ rer.jpg')
Beispiel #2
0
def test_escape(test_data):
    path = DayuPath(test_data['path'])
    assert path.escape() == test_data['result']