def test_cmd_env_def(self): """ Setup: --config on cmd, $fetchdata_CONFIG is set, $HOME/.fetchdata exists Result: load --config """ with ModifiedEnvironment(fetchdata_CONFIG=self.env_filename, HOME=self.tmpd): cfg = config.getConfig(self.cmd_filename) ae = self.assertEqual ae(["fetchdata"], cfg.sections()) ae(self.cmd_filename, cfg.get("fetchdata", "omit-patterns")) ae(self.cmd_run_coverage, cfg.getboolean("fetchdata", "run-coverage")) ae(self.cmd_logging, cfg.getboolean("fetchdata", "logging")) ae(self.env_no_skip_report, cfg.getboolean("fetchdata", "no-skip-report")) ae(self.default_version, cfg.getboolean("fetchdata", "version"))
def test_nocmd_env_def(self): """ Setup: no --config option, $fetchdata_CONFIG is set, $HOME/.fetchdata exists Result: load $fetchdata_CONFIG """ os.unlink(self.cmd_filename) with ModifiedEnvironment(fetchdata_CONFIG=self.env_filename, HOME=self.tmpd): cfg = config.getConfig() ae = self.assertEqual ar = self.assertRaises ae(["fetchdata"], cfg.sections()) ae(self.env_filename, cfg.get("fetchdata", "omit-patterns")) ar(configparser.NoOptionError, cfg.get, "fetchdata", "run-coverage") ae(self.env_logging, cfg.getboolean("fetchdata", "logging")) ae(self.env_no_skip_report, cfg.getboolean("fetchdata", "no-skip-report")) ae(self.default_version, cfg.getboolean("fetchdata", "version"))
def test_cmd_noenv_nodef(self): """ Setup: --config on cmd, $fetchdata_CONFIG unset, $HOME/.fetchdata does not exist Result: load --config """ os.unlink(self.env_filename) os.unlink(self.default_filename) with ModifiedEnvironment(fetchdata_CONFIG=None, HOME=self.tmpd): cfg = config.getConfig(self.cmd_filename) ae = self.assertEqual ar = self.assertRaises ae(["fetchdata"], cfg.sections()) ae(self.cmd_filename, cfg.get("fetchdata", "omit-patterns")) ae(self.cmd_run_coverage, cfg.getboolean("fetchdata", "run-coverage")) ae(self.cmd_logging, cfg.getboolean("fetchdata", "logging")) ar(configparser.NoOptionError, cfg.getboolean, "fetchdata", "no-skip-report") ar(configparser.NoOptionError, cfg.getboolean, "fetchdata", "version")
def test_nocmd_noenv_nodef(self): """ Setup: no --config option, $fetchdata_CONFIG unset, no $HOME/.fetchdata Result: empty config """ os.unlink(self.default_filename) os.unlink(self.env_filename) os.unlink(self.cmd_filename) with ModifiedEnvironment(fetchdata_CONFIG=None, HOME=self.tmpd): cfg = config.getConfig() ae = self.assertEqual ar = self.assertRaises ae([], cfg.sections()) ar(configparser.NoSectionError, cfg.get, "fetchdata", "omit-patterns") ar(configparser.NoSectionError, cfg.get, "fetchdata", "run-coverage") ar(configparser.NoSectionError, cfg.get, "fetchdata", "logging") ar(configparser.NoSectionError, cfg.get, "fetchdata", "no-skip-report") ar(configparser.NoSectionError, cfg.get, "fetchdata", "version")