Example #1
0
    def test_overwrite(self):
        """
        Non-default command-line argument values overwrite config values.
        """
        # This config environment should set the values we look at to False and
        # a filename in omit-patterns
        s = StringIO()
        gs = hmaStream(s)
        saved_stdout = config.sys.stdout
        config.sys.stdout = gs
        self.addCleanup(setattr, config.sys, 'stdout', saved_stdout)
        with ModifiedEnvironment(hma_CONFIG=self.env_filename, HOME=self.tmpd):
            new_args = copy.deepcopy(config.default_args)

            new_args.omit_patterns  = 'omitstuff'
            new_args.run_coverage   = True
            new_args.logging        = True
            new_args.no_skip_report = True
            new_args.version        = True

            new_args.config = self.cmd_filename
            computed_args = config.mergeConfig(new_args, testing=True)

            self.assertEqual(computed_args.omit_patterns,  'omitstuff')
            self.assertEqual(computed_args.run_coverage,   new_args.run_coverage)
            self.assertEqual(computed_args.logging,        new_args.logging)
            self.assertEqual(computed_args.no_skip_report, new_args.no_skip_report)
            self.assertEqual(computed_args.version,        new_args.version)
Example #2
0
 def test_targets(self):
     """
     The targets passed in make it through mergeConfig, and the specified
     target gets parsed
     """
     config.sys.argv = ['', 'target1', 'target2']
     args = config.parseArguments()
     args = config.mergeConfig(args)
     self.assertEqual(args.targets, ['target1', 'target2'])
Example #3
0
 def test_no_overwrite(self):
     """
     Default unspecified command-line args do not overwrite config values.
     """
     # This config environment should set logging to True
     with ModifiedEnvironment(hma_CONFIG=self.env_filename, HOME=""):
         # The default for logging in arguments is False
         da = copy.deepcopy(config.default_args)
         del(da.logging)
         computed_args = config.mergeConfig(da, testing=True)
         self.assertEqual(computed_args.logging, True)
Example #4
0
 def test_specified_command_line(self):
     """
     Specified command-line arguments always overwrite config file values
     """
     with ModifiedEnvironment(HOME=self.tmpd):
         new_args = copy.deepcopy(config.default_args)
         new_args.failfast = True # same as config, for sanity
         new_args.logging = True # different than config, not default
         del(new_args.version) # Not in arguments, should get config value
         new_args.termcolor = False # override config, set back to default
         computed_args = config.mergeConfig(new_args, testing=True)
         self.assertEqual(computed_args.failfast, True)
         self.assertEqual(computed_args.logging, True)
         self.assertEqual(computed_args.version, False)
         self.assertEqual(computed_args.termcolor, False)