'Make sure that the created subdirectories are correctly removed when empty.'

def test_subdirectory_removal(self):

    self.cache.set(u'foo', u'bar')
    key = self.cache.make_key(u'foo')
    keyhash = hashlib.md5(key.encode()).hexdigest()
    keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:])
    self.assertTrue(os.path.exists(keypath))
    self.cache.delete(u'foo')
    self.assertTrue((not os.path.exists(keypath)))
    self.assertTrue((not os.path.exists(os.path.dirname(keypath))))
    self.assertTrue((not os.path.exists(os.path.dirname(os.path.dirname(keypath)))))
