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

def test_subdirectory_removal(self):

    self.cache.set('foo', 'bar')
    keyhash = md5_constructor('foo').hexdigest()
    keypath = os.path.join(self.dirname, keyhash[:2], keyhash[2:4], keyhash[4:])
    self.assert_(os.path.exists(keypath))
    self.cache.delete('foo')
    self.assert_((not os.path.exists(keypath)))
    self.assert_((not os.path.exists(os.path.dirname(keypath))))
    self.assert_((not os.path.exists(os.path.dirname(os.path.dirname(keypath)))))
