def _get_environment(self):
        if self._cache.get("_environment") is None:
            name = self.get("environmentname", "default")
            if name:
                db = self.session
                try:
                    env = db.query(models.Environment).filter(models.Environment.name==name).one()
                except config.NoResultFound as err:
                    raise config.ConfigError("Bad environmentname %r: %s" % (name, err))
                username = self.get("username") # username should be set by test runner
                if username:
                    if env.is_owned():
                        if env.owner.username != username:
                            raise config.ConfigError("Environment is currently owned by: %s" % (env.owner,))
                    env.set_owner_by_username(db, username)
                env = EnvironmentRuntime(db, env, self.logfile)
                self._cache["_environment"] = env
            else:
                raise config.ConfigError, "Bad environmentname %r." % (name,)
        return self._cache["_environment"]
Get the Environment object defined by the test configuration.
dataset/ETHPy150Open kdart/pycopia/QA/pycopia/QA/config.py/RootContainer._get_environment