Example #1
0
 def test_cmd_env_def(self):
     """
     Setup: --config on cmd, $GREEN_CONFIG is set, $HOME/.green exists
     Result: load --config
     """
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename, HOME=self.tmpd):
         cfg = config.getConfig(self.cmd_filename)
         ae = self.assertEqual
         ae(["green"],             cfg.sections())
         ae(self.cmd_filename,     cfg.get("green", "omit-patterns"))
         ae(self.cmd_run_coverage, cfg.getboolean("green", "run-coverage"))
         ae(self.cmd_logging,      cfg.getboolean("green", "logging"))
         ae(self.env_html,         cfg.getboolean("green", "html"))
         ae(self.default_version,  cfg.getboolean("green", "version"))
Example #2
0
 def test_cmd_env_def(self):
     """
     Setup: --config on cmd, $GREEN_CONFIG is set, $HOME/.green exists
     Result: load --config
     """
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename,
                              HOME=self.tmpd):
         cfg = config.getConfig(self.cmd_filename)
         ae = self.assertEqual
         ae(["green"],               cfg.sections())
         ae(self.cmd_filename,       cfg.get("green", "omit-patterns"))
         ae(self.cmd_run_coverage,   cfg.getboolean("green", "run-coverage"))
         ae(self.cmd_logging,        cfg.getboolean("green", "logging"))
         ae(self.env_no_skip_report, cfg.getboolean("green", "no-skip-report"))
         ae(self.default_version,    cfg.getboolean("green", "version"))
Example #3
0
 def test_cmd_noenv_def(self):
     """
     Setup: --config on cmd, $GREEN_CONFIG unset, $HOME/.green exists
     Result: load --config
     """
     os.unlink(self.env_filename)
     with ModifiedEnvironment(GREEN_CONFIG=None, HOME=self.tmpd):
         cfg = config.getConfig(self.cmd_filename)
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.cmd_filename,          cfg.get("green", "omit-patterns"))
         ae(self.cmd_run_coverage,      cfg.getboolean("green", "run-coverage"))
         ae(self.cmd_logging,           cfg.getboolean("green", "logging"))
         ar(configparser.NoOptionError, cfg.getboolean, "green", "no-skip-report")
         ae(self.default_version,       cfg.getboolean("green", "version"))
Example #4
0
 def test_nocmd_env_def(self):
     """
     Setup: no --config option, $GREEN_CONFIG is set, $HOME/.green exists
     Result: load $GREEN_CONFIG
     """
     os.unlink(self.cmd_filename)
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename, HOME=self.tmpd):
         cfg = config.getConfig()
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.env_filename,          cfg.get("green", "omit-patterns"))
         ar(configparser.NoOptionError, cfg.get, "green", "run-coverage")
         ae(self.env_logging,           cfg.getboolean("green", "logging"))
         ae(self.env_html,              cfg.getboolean("green", "html"))
         ae(self.default_version,       cfg.getboolean("green", "version"))
Example #5
0
 def test_cmd_env_nodef(self):
     """
     Setup: --config on cmd, $GREEN_CONFIG is set, $HOME/.green does not
         exist
     Result: load --config
     """
     os.unlink(self.default_filename)
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename, HOME=self.tmpd):
         cfg = config.getConfig(self.cmd_filename)
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.cmd_filename,          cfg.get("green", "omit"))
         ae(self.cmd_run_coverage,      cfg.getboolean("green", "run-coverage"))
         ae(self.cmd_logging,           cfg.getboolean("green", "logging"))
         ae(self.env_html,              cfg.getboolean("green", "html"))
         ar(configparser.NoOptionError, cfg.getboolean, "green", "version")
Example #6
0
 def test_nocmd_noenv_nodef(self):
     """
     Setup: no --config option, $GREEN_CONFIG unset, no $HOME/.green
     Result: empty config
     """
     os.unlink(self.default_filename)
     os.unlink(self.env_filename)
     os.unlink(self.cmd_filename)
     with ModifiedEnvironment(GREEN_CONFIG=None, HOME=self.tmpd):
         cfg = config.getConfig()
         ae = self.assertEqual
         ar = self.assertRaises
         ae([], cfg.sections())
         ar(configparser.NoSectionError, cfg.get, "green", "omit-patterns")
         ar(configparser.NoSectionError, cfg.get, "green", "run-coverage")
         ar(configparser.NoSectionError, cfg.get, "green", "logging")
         ar(configparser.NoSectionError, cfg.get, "green", "no-skip-report")
         ar(configparser.NoSectionError, cfg.get, "green", "version")
Example #7
0
 def test_nocmd_env_nodef(self):
     """
     Setup: no --config option, $GREEN_CONFIG is set, $HOME/.green does not
         exist
     Result: load $GREEN_CONFIG
     """
     os.unlink(self.cmd_filename)
     os.unlink(self.default_filename)
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename,
                              HOME=self.tmpd):
         cfg = config.getConfig()
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.env_filename,          cfg.get("green", "omit-patterns"))
         ar(configparser.NoOptionError, cfg.get, "green", "run-coverage")
         ae(self.env_logging,           cfg.getboolean("green", "logging"))
         ae(self.env_no_skip_report,    cfg.getboolean("green", "no-skip-report"))
         ar(configparser.NoOptionError, cfg.getboolean, "green", "version")
Example #8
0
 def test_nocmd_noenv_nodef_setup(self):
     """
     Setup: no --config option, $GREEN_CONFIG unset, no $HOME/.green,
         setup.cfg exists
     Result: empty config
     """
     os.unlink(self.default_filename)
     os.unlink(self.env_filename)
     os.unlink(self.cmd_filename)
     with ModifiedEnvironment(GREEN_CONFIG=None, HOME=self.tmpd):
         cfg = config.getConfig()
         ae = self.assertEqual
         ar = self.assertRaises
         ae(self.setup_verbose, cfg.getint("green", "verbose"))
         ae(self.setup_failfast, cfg.getboolean("green", "failfast"))
         ar(configparser.NoOptionError, cfg.get, "green", "omit-patterns")
         ar(configparser.NoOptionError, cfg.get, "green", "run-coverage")
         ar(configparser.NoOptionError, cfg.get, "green", "logging")
         ar(configparser.NoOptionError, cfg.get, "green", "no-skip-report")
         ar(configparser.NoOptionError, cfg.get, "green", "version")
Example #9
0
 def test_cmd_env_nodef_setup(self):
     """
     Setup: --config on cmd, $GREEN_CONFIG is set, $HOME/.green does not
         exist, setup.cfg exists
     Result: load --config
     """
     os.unlink(self.default_filename)
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename,
                              HOME=self.tmpd):
         cfg = config.getConfig(self.cmd_filename)
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.cmd_filename,          cfg.get("green", "omit-patterns"))
         ae(self.cmd_run_coverage,      cfg.getboolean("green", "run-coverage"))
         ae(self.cmd_logging,           cfg.getboolean("green", "logging"))
         ae(self.env_no_skip_report,    cfg.getboolean("green", "no-skip-report"))
         ae(self.setup_verbose,         cfg.getint("green", "verbose"))
         ae(self.setup_failfast,        cfg.getboolean("green", "failfast"))
         ar(configparser.NoOptionError, cfg.getboolean, "green", "version")
Example #10
0
 def test_nocmd_env_cwd(self):
     """
     Setup: no --config option, $GREEN_CONFIG is set, .green in local dir,
     Result: load $GREEN_CONFIG
     """
     os.chdir(self.tmpd) # setUp is already set to restore us to our pre-testing cwd
     os.unlink(self.cmd_filename)
     os.remove(self.setup_filename)
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename,
                              HOME=self.tmpd):
         cfg = config.getConfig()
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.default_filename,      cfg.get("green", "omit-patterns"))
         ar(configparser.NoOptionError, cfg.get, "green", "run-coverage")
         ae(self.default_logging,           cfg.getboolean("green", "logging"))
         ae(self.env_no_skip_report,    cfg.getboolean("green", "no-skip-report"))
         ae(self.default_version,       cfg.getboolean("green", "version"))
         ar(configparser.NoOptionError, cfg.getint, "green", "verbose")
Example #11
0
 def test_nocmd_noenv_nodef_setup(self):
     """
     Setup: no --config option, $GREEN_CONFIG unset, no $HOME/.green,
         setup.cfg exists
     Result: empty config
     """
     os.unlink(self.default_filename)
     os.unlink(self.env_filename)
     os.unlink(self.cmd_filename)
     with ModifiedEnvironment(GREEN_CONFIG=None, HOME=self.tmpd):
         cfg = config.getConfig()
         ae = self.assertEqual
         ar = self.assertRaises
         ae(self.setup_verbose, cfg.getint("green", "verbose"))
         ae(self.setup_failfast, cfg.getboolean("green", "failfast"))
         ar(configparser.NoOptionError, cfg.get, "green", "omit-patterns")
         ar(configparser.NoOptionError, cfg.get, "green", "run-coverage")
         ar(configparser.NoOptionError, cfg.get, "green", "logging")
         ar(configparser.NoOptionError, cfg.get, "green", "no-skip-report")
         ar(configparser.NoOptionError, cfg.get, "green", "version")
Example #12
0
 def test_cmd_env_nodef_setup(self):
     """
     Setup: --config on cmd, $GREEN_CONFIG is set, $HOME/.green does not
         exist, setup.cfg exists
     Result: load --config
     """
     os.unlink(self.default_filename)
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename,
                              HOME=self.tmpd):
         cfg = config.getConfig(self.cmd_filename)
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.cmd_filename,          cfg.get("green", "omit-patterns"))
         ae(self.cmd_run_coverage,      cfg.getboolean("green", "run-coverage"))
         ae(self.cmd_logging,           cfg.getboolean("green", "logging"))
         ae(self.env_no_skip_report,    cfg.getboolean("green", "no-skip-report"))
         ae(self.setup_verbose,         cfg.getint("green", "verbose"))
         ae(self.setup_failfast,        cfg.getboolean("green", "failfast"))
         ar(configparser.NoOptionError, cfg.getboolean, "green", "version")
Example #13
0
 def test_nocmd_env_cwd(self):
     """
     Setup: no --config option, $GREEN_CONFIG is set, .green in local dir,
     Result: load $GREEN_CONFIG
     """
     os.chdir(self.tmpd) # setUp is already set to restore us to our pre-testing cwd
     os.unlink(self.cmd_filename)
     os.remove(self.setup_filename)
     with ModifiedEnvironment(GREEN_CONFIG=self.env_filename,
                              HOME=self.tmpd):
         cfg = config.getConfig()
         ae = self.assertEqual
         ar = self.assertRaises
         ae(["green"],                  cfg.sections())
         ae(self.default_filename,      cfg.get("green", "omit-patterns"))
         ar(configparser.NoOptionError, cfg.get, "green", "run-coverage")
         ae(self.default_logging,           cfg.getboolean("green", "logging"))
         ae(self.env_no_skip_report,    cfg.getboolean("green", "no-skip-report"))
         ae(self.default_version,       cfg.getboolean("green", "version"))
         ar(configparser.NoOptionError, cfg.getint, "green", "verbose")