'Imitate eventlet green thread re-use and ensure trash works.'

def test_trash_users(self):

    class test_local(object, ):
        def __getattribute__(self, name):
            return object.__getattribute__(self, name)
        def __setattr__(self, name, value):
            return object.__setattr__(self, name, value)
        def __delattr__(self, name):
            return object.__delattr__(self, name)
    threading.local = test_local
    USERS = ['test1', 'test2']
    CLEANUP = []
    try:
        for user in USERS:
            self.cluster.fs.setuser(user)
            self.cluster.fs.create_home_dir()
            CLEANUP.append(self.cluster.fs.get_home_dir())
            PATH = self.cluster.fs.join(self.cluster.fs.get_home_dir(), 'trash_test')
            self.cluster.fs.open(PATH, 'w').close()
            assert_true(self.cluster.fs.exists(PATH))
            self.cluster.fs.remove(PATH)
            assert_false(self.cluster.fs.exists(PATH))
            assert_true(self.cluster.fs.exists(self.cluster.fs.trash_path(PATH)))
    finally:
        reload(threading)
        self.cluster.fs.setuser(self.cluster.superuser)
        for directory in CLEANUP:
            try:
                self.cluster.fs.rmtree(dir)
            except Exception as ex:
                LOG.error(('Failed    to    cleanup    %s:    %s' % (directory, ex)))
