def test_sanitize_filename_restricted(self):
    self.assertEqual(sanitize_filename('abc', restricted=True), 'abc')
    self.assertEqual(sanitize_filename('abc_d-e', restricted=True), 'abc_d-e')
    self.assertEqual(sanitize_filename('123', restricted=True), '123')
    self.assertEqual('abc_de', sanitize_filename('abc/de', restricted=True))
    self.assertFalse(('/' in sanitize_filename('abc/de///', restricted=True)))
    self.assertEqual('abc_de', sanitize_filename('abc/<>\\*|de', restricted=True))
    self.assertEqual('xxx', sanitize_filename('xxx/<>\\*|', restricted=True))
    self.assertEqual('yes_no', sanitize_filename('yes? no', restricted=True))
    self.assertEqual('this_-_that', sanitize_filename('this: that', restricted=True))
    tests = 'aäb中国的c'
    self.assertEqual(sanitize_filename(tests, restricted=True), 'aab_c')
    self.assertTrue((sanitize_filename('ö', restricted=True) != ''))
    forbidden = '"\x00\\/&!: \'\t\n()[]{}$;`^,#'
    for fc in forbidden:
        for fbc in forbidden:
            self.assertTrue((fbc not in sanitize_filename(fc, restricted=True)))
    self.assertEqual(sanitize_filename('大声带 - Song', restricted=True), 'Song')
    self.assertEqual(sanitize_filename('总统: Speech', restricted=True), 'Speech')
    self.assertTrue((sanitize_filename('-', restricted=True) != ''))
    self.assertTrue((sanitize_filename(':', restricted=True) != ''))
    self.assertEqual(sanitize_filename('ÂÃÄÀÁÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖŐØŒÙÚÛÜŰÝÞßàáâãäåæçèéêëìíîïðñòóôõöőøœùúûüűýþÿ', restricted=True), 'AAAAAAAECEEEEIIIIDNOOOOOOOOEUUUUUYTHssaaaaaaaeceeeeiiiionooooooooeuuuuuythy')
def test_sanitize_filename_restricted(self):
    self.assertEqual(sanitize_filename('abc', restricted=True), 'abc')
    self.assertEqual(sanitize_filename('abc_d-e', restricted=True), 'abc_d-e')
    self.assertEqual(sanitize_filename('123', restricted=True), '123')
    self.assertEqual('abc_de', sanitize_filename('abc/de', restricted=True))
    self.assertFalse(('/' in sanitize_filename('abc/de///', restricted=True)))
    self.assertEqual('abc_de', sanitize_filename('abc/<>\\*|de', restricted=True))
    self.assertEqual('xxx', sanitize_filename('xxx/<>\\*|', restricted=True))
    self.assertEqual('yes_no', sanitize_filename('yes? no', restricted=True))
    self.assertEqual('this_-_that', sanitize_filename('this: that', restricted=True))
    tests = 'aäb中国的c'
    self.assertEqual(sanitize_filename(tests, restricted=True), 'aab_c')
    self.assertTrue((sanitize_filename('ö', restricted=True) != ))
    forbidden = '"\x00\\/&!: \'\t\n()[]{}$;`^,#'
    for fc in forbidden:
        for fbc in forbidden:
            self.assertTrue((fbc not in sanitize_filename(fc, restricted=True)))
    self.assertEqual(sanitize_filename('大声带 - Song', restricted=True), 'Song')
    self.assertEqual(sanitize_filename('总统: Speech', restricted=True), 'Speech')
    self.assertTrue((sanitize_filename('-', restricted=True) != ))
    self.assertTrue((sanitize_filename(':', restricted=True) != ))
    self.assertEqual(sanitize_filename('ÂÃÄÀÁÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖŐØŒÙÚÛÜŰÝÞßàáâãäåæçèéêëìíîïðñòóôõöőøœùúûüűýþÿ', restricted=True), 'AAAAAAAECEEEEIIIIDNOOOOOOOOEUUUUUYTHssaaaaaaaeceeeeiiiionooooooooeuuuuuythy')