예제 #1
0
    def test_replace_whitespace(self):
        whitelist = DEFAULT_WHITELIST_FILE
        replace = {
            ' ': '_',
        }

        self.assertEqual(
            FilenameTransformer.clean('f o o.xml', whitelist, replace),
            'f_o_o.xml')
예제 #2
0
    def test_custom_replace(self):
        replace = {
            '0': 'o',
            ' ': '_',
            ':': '_',
        }

        whitelist = DEFAULT_WHITELIST_FILE
        self.assertEqual(
            FilenameTransformer.clean('f:0o.  xml', whitelist,
                                      replace=replace), 'f_oo.__xml')
예제 #3
0
 def test_without_unicode_normalization(self):
     whitelist = DEFAULT_WHITELIST_FILE
     self.assertEqual(
         FilenameTransformer.clean('fåoäoö.xml',
                                   whitelist,
                                   normalize_unicode=False), 'foo.xml')
예제 #4
0
 def test_custom_whitelist(self):
     whitelist = '.4{}'.format(string.ascii_letters)
     self.assertEqual(
         FilenameTransformer.clean('f1o2o3.x4m5l6', whitelist=whitelist),
         'foo.x4ml')
예제 #5
0
 def test_default_remove_special_characters(self):
     whitelist = DEFAULT_WHITELIST_FILE
     self.assertEqual(
         FilenameTransformer.clean('$f?o!o).x%m#l+', whitelist), 'foo.xml')
예제 #6
0
 def test_default_replace_swedish_characters(self):
     whitelist = DEFAULT_WHITELIST_FILE
     self.assertEqual(FilenameTransformer.clean('åäö.xml', whitelist),
                      'aao.xml')
예제 #7
0
 def test_default_correct(self):
     whitelist = DEFAULT_WHITELIST_FILE
     self.assertEqual(FilenameTransformer.clean('foo.xml', whitelist),
                      'foo.xml')