def testD(self): """test documentation""" config = Configuration() config.section_("Section1") config.Section1.Parameter1 = True config.Section1.Parameter2 = "string" config.Section1.Parameter3 = 123 config.Section1.Parameter4 = 123.456 config.Section1.Parameter5 = {"test1": "test2", "test3": 123} config.Section1.document_("""This is Section1""") config.Section1.document_("""This is Section1.Parameter1""", "Parameter1") config.Section1.document_("""This is Section1.Parameter2""", "Parameter2") config.Section1.document_( """This is Section1.Parameter3\n with multiline comments""", "Parameter3") try: config.Section1.documentedString_() except Exception as ex: msg = "Error calling ConfigSection.documentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg) try: config.Section1.commentedString_() except Exception as ex: msg = "Error calling ConfigSection.commentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg) try: config.documentedString_() except Exception as ex: msg = "Error calling Configuration.documentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg) try: config.commentedString_() except Exception as ex: msg = "Error calling Configuration.commentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg)
def testD(self): """test documentation""" config = Configuration() config.section_("Section1") config.Section1.Parameter1 = True config.Section1.Parameter2 = "string" config.Section1.Parameter3 = 123 config.Section1.Parameter4 = 123.456 config.Section1.Parameter5 = {"test1" : "test2", "test3" : 123} config.Section1.document_("""This is Section1""") config.Section1.document_("""This is Section1.Parameter1""", "Parameter1") config.Section1.document_("""This is Section1.Parameter2""", "Parameter2") config.Section1.document_("""This is Section1.Parameter3\n with multiline comments""", "Parameter3") try: config.Section1.documentedString_() except Exception as ex: msg = "Error calling ConfigSection.documentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg) try: config.Section1.commentedString_() except Exception as ex: msg = "Error calling ConfigSection.commentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg) try: config.documentedString_() except Exception as ex: msg = "Error calling Configuration.documentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg) try: config.commentedString_() except Exception as ex: msg = "Error calling Configuration.commentedString_:\n" msg += "%s\n" % str(ex) self.fail(msg)
def testE(self): """test save/load """ testValues = [ "string", 123, 123.456, ["list", 789, 10.1 ], { "dict1" : "value", "dict2" : 10.0 } ] config = Configuration() for x in range(0, 5): config.section_("Section%s" % x) config.component_("Component%s" % x) sect = getattr(config, "Section%s" % x) comp = getattr(config, "Component%s" % x) sect.document_("This is Section%s" % x) comp.document_("This is Component%s" % x) for i in range(0, 5): setattr(comp, "Parameter%s" % i, testValues[i]) setattr(sect, "Parameter%s" % i, testValues[i]) comp.document_("This is Parameter%s" % i, "Parameter%s" %i) sect.document_("This is Parameter%s" %i, "Parameter%s" %i) stringSave = str(config) documentSave = config.documentedString_() commentSave = config.commentedString_() saveConfigurationFile(config, self.normalSave) saveConfigurationFile(config, self.docSave, document = True) saveConfigurationFile(config, self.commentSave, comment = True) plainConfig = loadConfigurationFile(self.normalSave) docConfig = loadConfigurationFile(self.docSave) commentConfig = loadConfigurationFile(self.commentSave)
def testE(self): """test save/load """ testValues = [ "string", 123, 123.456, ["list", 789, 10.1 ], { "dict1" : "value", "dict2" : 10.0 } ] config = Configuration() for x in range(0, 5): config.section_("Section%s" % x) config.component_("Component%s" % x) sect = getattr(config, "Section%s" % x) comp = getattr(config, "Component%s" % x) sect.document_("This is Section%s" % x) comp.document_("This is Component%s" % x) for i in range(0, 5): setattr(comp, "Parameter%s" % i, testValues[i]) setattr(sect, "Parameter%s" % i, testValues[i]) comp.document_("This is Parameter%s" % i, "Parameter%s" %i) sect.document_("This is Parameter%s" %i, "Parameter%s" %i) dummyStringSave = str(config) dummyDocumentSave = config.documentedString_() dummyCommentSave = config.commentedString_() saveConfigurationFile(config, self.normalSave) saveConfigurationFile(config, self.docSave, document = True) saveConfigurationFile(config, self.commentSave, comment = True) dummyPlainConfig = loadConfigurationFile(self.normalSave) dummyDocConfig = loadConfigurationFile(self.docSave) dummyCommentConfig = loadConfigurationFile(self.commentSave)