Esempio n. 1
0
 def test__init__should_accept_a_filename_or_string(self):
     init = self.__class__.test_parameters
     P1 = ConfigParserParameterSet(init)
     with open("test_file", "w") as f:
         f.write(init)
     P2 = ConfigParserParameterSet("test_file")
     self.assertEqual(P1.as_dict(), P2.as_dict())
     os.remove("test_file")
Esempio n. 2
0
 def test__init__should_accept_a_filename_or_string(self):
     init = self.__class__.test_parameters
     P1 = ConfigParserParameterSet(init)
     with open("test_file", "w") as f:
         f.write(init)
     P2 = ConfigParserParameterSet("test_file")
     self.assertEqual(P1.as_dict(), P2.as_dict())
     os.remove("test_file")
Esempio n. 3
0
 def test__update_should_handle_dots_appropriately(self):
     init = self.__class__.test_parameters
     P = ConfigParserParameterSet(init)
     P.update({"sectionA.a": 5, "sectionA.c": 4, "sectionC.e": 9})
     self.assertEqual(P.as_dict(), {"sectionA": dict(a="5", b="3", c="4"),
                                    "sectionB": dict(c="hello", d="world"),
                                    "sectionC": dict(e="9")})
Esempio n. 4
0
 def test__update_should_handle_dots_appropriately(self):
     init = self.__class__.test_parameters
     P = ConfigParserParameterSet(init)
     P.update({"sectionA.a": 5, "sectionA.c": 4, "sectionC.e": 9})
     self.assertEqual(
         P.as_dict(), {
             "sectionA": dict(a="5", b="3", c="4"),
             "sectionB": dict(c="hello", d="world"),
             "sectionC": dict(e="9")
         })
Esempio n. 5
0
 def test__pretty__output_should_be_useable_to_create_an_identical_parameterset(self):
     init = self.__class__.test_parameters
     P1 = ConfigParserParameterSet(init)
     P2 = ConfigParserParameterSet(P1.pretty())
     self.assertEqual(P1.as_dict(), P2.as_dict())
Esempio n. 6
0
 def test__init__should_accept_an_empty_initializer(self):
     P = ConfigParserParameterSet("")
     self.assertEqual(P.as_dict(), {})
Esempio n. 7
0
 def test__pretty__output_should_be_useable_to_create_an_identical_parameterset(
         self):
     init = self.__class__.test_parameters
     P1 = ConfigParserParameterSet(init)
     P2 = ConfigParserParameterSet(P1.pretty())
     self.assertEqual(P1.as_dict(), P2.as_dict())
Esempio n. 8
0
 def test__init__should_accept_an_empty_initializer(self):
     P = ConfigParserParameterSet("")
     self.assertEqual(P.as_dict(), {})