コード例 #1
0
    def test_bad(self):
        'Test various pieces of bad input.'

        for (input_string, expected) in bad_inputs:
            inp = StringIO(input_string)
            try:
                pref_list = yaml.safe_load(inp)
                generate_code(pref_list)
                self.assertEqual(0, 1)
            except ValueError as e:
                self.assertEqual(str(e), expected)
コード例 #2
0
    def test_good(self):
        "Test various pieces of good input."
        inp = StringIO(good_input)
        pref_list = yaml.safe_load(inp)
        code = generate_code(pref_list, "(string input)")

        self.assertEqual(good["static_pref_list_all_h"], code["static_pref_list_all_h"])

        self.assertEqual(good["static_prefs_all_h"], code["static_prefs_all_h"])

        self.assertEqual(
            good["static_pref_list_group_h"]["my"],
            code["static_pref_list_group_h"]["my"],
        )
        self.assertEqual(
            good["static_pref_list_group_h"]["my_dashed"],
            code["static_pref_list_group_h"]["my_dashed"],
        )

        self.assertEqual(
            good["static_prefs_group_h"]["my"], code["static_prefs_group_h"]["my"]
        )

        self.assertEqual(
            good["static_prefs_c_getters_cpp"], code["static_prefs_c_getters_cpp"]
        )

        self.assertEqual(good["static_prefs_rs"], code["static_prefs_rs"])
コード例 #3
0
    def test_good(self):
        'Test various pieces of good input.'
        inp = StringIO(good_input)
        pref_list = yaml.safe_load(inp)
        code = generate_code(pref_list)

        self.assertEqual(good['static_pref_list_all_h'],
                         code['static_pref_list_all_h'])

        self.assertEqual(good['static_prefs_all_h'],
                         code['static_prefs_all_h'])

        self.assertEqual(good['static_pref_list_group_h']['my'],
                         code['static_pref_list_group_h']['my'])
        self.assertEqual(good['static_pref_list_group_h']['my_dashed'],
                         code['static_pref_list_group_h']['my_dashed'])

        self.assertEqual(good['static_prefs_group_h']['my'],
                         code['static_prefs_group_h']['my'])

        self.assertEqual(good['static_prefs_c_getters_cpp'],
                         code['static_prefs_c_getters_cpp'])

        self.assertEqual(good['static_prefs_rs'], code['static_prefs_rs'])