コード例 #1
0
ファイル: test_config.py プロジェクト: danorama/pyexperiment
 def test_override_with_args_level(self):
     """Test adding config options from dictionary at higher level
     """
     conf.load(self.filename)
     conf["section_1.section_12.a"] = "15"
     self.assertEqual(conf["section_1.section_12.a"], "15")
     conf.override_with_args([("section_1.section_12.a", "13")])
     self.assertEqual(conf["section_1.section_12.a"], "13")
コード例 #2
0
 def test_override_with_args_level(self):
     """Test adding config options from dictionary at higher level
     """
     conf.load(self.filename)
     conf['section_1.section_12.a'] = '15'
     self.assertEqual(conf['section_1.section_12.a'], '15')
     conf.override_with_args([('section_1.section_12.a', '13')])
     self.assertEqual(conf['section_1.section_12.a'], '13')
コード例 #3
0
ファイル: test_config.py プロジェクト: danorama/pyexperiment
 def test_override_with_args(self):
     """Test adding config options from dictionary
     """
     conf.load(self.filename)
     self.assertTrue("section_1.a" in conf)
     self.assertEqual(conf["section_1.a"], "12")
     conf.override_with_args([("section_1.a", "13")])
     self.assertEqual(conf["section_1.a"], "13")
コード例 #4
0
 def test_override_with_args(self):
     """Test adding config options from dictionary
     """
     conf.load(self.filename)
     self.assertTrue('section_1.a' in conf)
     self.assertEqual(conf['section_1.a'], '12')
     conf.override_with_args([('section_1.a', '13')])
     self.assertEqual(conf['section_1.a'], '13')
コード例 #5
0
 def test_override_with_args_level(self):
     """Test adding config options from dictionary at higher level
     """
     conf.load(self.filename)
     conf['section_1.section_12.a'] = '15'
     self.assertEqual(conf['section_1.section_12.a'], '15')
     conf.override_with_args([('section_1.section_12.a', '13')])
     self.assertEqual(conf['section_1.section_12.a'], '13')
コード例 #6
0
 def test_override_with_args(self):
     """Test adding config options from dictionary
     """
     conf.load(self.filename)
     self.assertTrue('section_1.a' in conf)
     self.assertEqual(conf['section_1.a'], '12')
     conf.override_with_args([('section_1.a', '13')])
     self.assertEqual(conf['section_1.a'], '13')
コード例 #7
0
ファイル: test_config.py プロジェクト: danorama/pyexperiment
    def test_override_with_args_spec(self):
        """Test adding config options with a spec
        """
        spec = "[section_1]\n" "a = integer(min=0, default=5, max=13)"

        conf.load(self.filename, spec=([option.encode() for option in spec.split("\n")]))
        conf.override_with_args([("section_1.a", "13")])
        self.assertEqual(conf["section_1.a"], "13")
        conf.validate_config(conf.base)
        self.assertEqual(conf["section_1.a"], 13)
コード例 #8
0
    def test_override_with_args_spec(self):
        """Test adding config options with a spec
        """
        spec = ("[section_1]\n" "a = integer(min=0, default=5, max=13)")

        conf.load(self.filename,
                  spec=([option.encode() for option in spec.split('\n')]))
        conf.override_with_args([('section_1.a', '13')])
        self.assertEqual(conf['section_1.a'], '13')
        conf.validate_config(conf.base)
        self.assertEqual(conf['section_1.a'], 13)
コード例 #9
0
ファイル: test_config.py プロジェクト: danorama/pyexperiment
 def test_override_with_args_wrong(self):
     """Test adding config options with a wrong spec
     """
     spec = "[section_1]\n" "a = integer(min=0, default=5, max=12)"
     expected_error = (
         r"Configuration does not adhere to the specification: "
         r"\[\(\['section_1'\], 'a', "
         r"VdtValueTooBigError\('the value \"13\" is too big.',\)\)\]"
     )
     conf.load(self.filename, spec=([option.encode() for option in spec.split("\n")]))
     conf.override_with_args([("section_1.a", "13")])
     self.assertRaisesRegexp(ValueError, expected_error, conf.validate_config, conf.base)
コード例 #10
0
 def test_override_with_args_wrong(self):
     """Test adding config options with a wrong spec
     """
     spec = ("[section_1]\n" "a = integer(min=0, default=5, max=12)")
     expected_error = (
         r"Configuration does not adhere to the specification: "
         r"\[\(\['section_1'\], 'a', "
         r"VdtValueTooBigError\('the value \"13\" is too big.',\)\)\]")
     conf.load(self.filename,
               spec=([option.encode() for option in spec.split('\n')]))
     conf.override_with_args([('section_1.a', '13')])
     self.assertRaisesRegexp(ValueError, expected_error,
                             conf.validate_config, conf.base)