'Test that adding formats does not create orphans if the file name algorithm changes'

def test_format_orphan(self):

    cache = self.init_cache()
    path = cache.format_abspath(1, u'FMT1')
    (base, name) = os.path.split(path)
    prefix = u'mushroomxx'
    os.rename(path, os.path.join(base, (prefix + name)))
    cache.fields[u'formats'].table.fname_map[1][u'FMT1'] = (prefix + os.path.splitext(name)[0])
    old = glob.glob(os.path.join(base, u'*.fmt1'))
    cache.add_format(1, u'FMT1', BytesIO('xxxx'), run_hooks=False)
    new = glob.glob(os.path.join(base, u'*.fmt1'))
    self.assertNotEqual(old, new)
    self.assertEqual(len(old), len(new))
    self.assertNotIn(prefix, cache.fields[u'formats'].format_fname(1, u'FMT1'))
