示例#1
0
    def test_meta_append_bad(self):
        """
        Test that the meta attribute "append" catches bad inputs.
        """
        base = hammer_config.load_config_from_string("""
foo:
    bar:
        adc: "yes"
        dac: "no"
        dsl: "scala"
""", is_yaml=True)
        meta = hammer_config.load_config_from_string("""
{
  "foo.bar.dsl": ["python"],
  "foo.bar.dsl_meta": "append",
  "foo.bar.dac": "current_weighted"
}
""", is_yaml=False)
        with self.assertRaises(ValueError):
            hammer_config.combine_configs([base, meta])

        meta = hammer_config.load_config_from_string("""
{
  "foo.bar.dsl": "c++",
  "foo.bar.dsl_meta": "append",
  "foo.bar.dac": "current_weighted"
}
""", is_yaml=False)
        with self.assertRaises(ValueError):
            hammer_config.combine_configs([base, meta])
示例#2
0
文件: test.py 项目: taylor-bsg/hammer
    def test_no_json_yaml_precedence(self) -> None:
        """
        Test that neither JSON nor YAML take precedence over each other.
        """
        yfp, ypath = tempfile.mkstemp(".yml")
        with open(ypath, 'w') as fy:
            fy.write("""
foo.bar: "i'm yaml"
""")
        jfp, jpath = tempfile.mkstemp(".json")
        with open(jpath, 'w') as fj:
            fj.write("""
{
    "foo.bar": "i'm json"
}
""")
        db1 = hammer_config.HammerDatabase()
        configs = hammer_config.load_config_from_paths([ypath, jpath])
        db1.update_core([hammer_config.combine_configs(configs)])
        self.assertEqual(db1.get_setting("foo.bar"), "i'm json")

        db2 = hammer_config.HammerDatabase()
        configs = hammer_config.load_config_from_paths([jpath, ypath])
        db2.update_core([hammer_config.combine_configs(configs)])
        self.assertEqual(db2.get_setting("foo.bar"), "i'm yaml")
示例#3
0
    def test_meta_append_bad(self) -> None:
        """
        Test that the meta attribute "append" catches bad inputs.
        """
        base = hammer_config.load_config_from_string("""
foo:
    bar:
        adc: "yes"
        dac: "no"
        dsl: "scala"
""", is_yaml=True)
        meta = hammer_config.load_config_from_string("""
{
  "foo.bar.dsl": ["python"],
  "foo.bar.dsl_meta": "append",
  "foo.bar.dac": "current_weighted"
}
""", is_yaml=False)
        with self.assertRaises(ValueError):
            hammer_config.combine_configs([base, meta])

        meta = hammer_config.load_config_from_string("""
{
  "foo.bar.dsl": "c++",
  "foo.bar.dsl_meta": "append",
  "foo.bar.dac": "current_weighted"
}
""", is_yaml=False)
        with self.assertRaises(ValueError):
            hammer_config.combine_configs([base, meta])
示例#4
0
 def project_config(self) -> dict:
     return hammer_config.combine_configs(self.project_configs)
示例#5
0
文件: driver.py 项目: ucb-bar/hammer
 def project_config(self) -> dict:
     return hammer_config.combine_configs(self.project_configs)