예제 #1
0
 def test_populate_from(self):
   conf = config.Config()
   self._validate_empty_contents(conf)
   conf.populate_from(
       datatypes.SimpleNamespace(**{k: 42 for k in config.ITEMS}))
   for k in config.ITEMS:
     self.assertEqual(getattr(conf, k), 42)
예제 #2
0
 def test_setup_cfg_from_subdir(self):
     with file_utils.Tempdir() as d:
         d.create_file('setup.cfg', SETUP_CFG)
         sub = d.create_directory('x/y/z')
         conf = config.Config()
         with file_utils.cd(sub):
             conf = config.read_config_file_or_die(None)
             self._validate_file_contents(conf, d.path)
예제 #3
0
 def test_populate_from_none(self):
   conf = config.Config()
   self._validate_empty_contents(conf)
   # None is a valid value.
   conf.populate_from(
       datatypes.SimpleNamespace(**{k: None for k in config.ITEMS}))
   for k in config.ITEMS:
     self.assertIsNone(getattr(conf, k))
예제 #4
0
 def config_from_defaults(self):
     defaults = self.parser.parse_args([])
     self.postprocess(defaults)
     conf = config.Config(*self.pytype_single_names)
     conf.populate_from(defaults)
     return conf
예제 #5
0
 def test_populate_from_empty(self):
     conf = config.Config()
     conf.populate_from(object())
     self._validate_empty_contents(conf)
예제 #6
0
 def test_str(self):
     str(config.Config())  # smoke test