def main(): test_all = True # test_all = False # Set up the environment. this_dir = os.path.dirname(os.path.abspath(__file__)) (path_to_tests, other) = os.path.split(this_dir) test_functions.set_path_to_tests(path_to_tests) if not os.path.isdir('temp'): os.mkdir('temp') fail = 0 gv.reset() if test_all: fail = testSedML(fail) fail = testCombine(fail) else: name = 'test_sedml' num = 33 class_name = 'SedRepeatedTask' list_of = '' test_case = 'attribute with different xml name' fail += run_test(name, num, class_name, test_case, list_of) test_functions.report('OTHER LIBRARY', fail, fails, not_tested) return fail
def main(): # Set up the environment this_dir = os.path.dirname(os.path.abspath(__file__)) (path_to_tests, other) = os.path.split(this_dir) test_functions.set_path_to_tests(path_to_tests) if not os.path.isdir('temp'): os.mkdir('temp') fail = 0 # run the individual tests # name = 'qual' # fail += run_test(name) # # name = 'lo_children' # fail += run_test(name) # name = 'lo_children' fail += run_xml_test(name) name = 'base_class' fail += run_xml_test(name) name = 'base_class' fail += run_xml_fail_tests(name) # # name = 'groups' # fail += run_xml_test(name) # name = 'groups' # fail += run_xml_fail_tests(name) name = 'qual' fail += run_xml_test(name) name = 'spatial' fail += run_xml_test(name) # Pytest parameterization is good for this sort of thing: fail += run_specific_xml_fail_tests(name, 8, 13) fail += run_specific_xml_fail_tests(name, 15, 19) fail += run_specific_xml_fail_tests(name, 22, 26) fail += run_specific_xml_fail_tests(name, 32, 36) fail += run_specific_xml_fail_tests(name, 41, 45) fail += run_specific_xml_fail_tests(name, 53, 54) fail += run_specific_xml_fail_tests(name, 60, 61) fail += run_specific_xml_fail_tests(name, 65, 66) #name = 'multi' #fail += run_specific_xml_fail_tests(name, 1, 2, 0) # # write summary test_functions.report('examples', fail, fails, not_tested) return fail
def main(): # set up the enivornment this_dir = os.path.dirname(os.path.abspath(__file__)) (path_to_tests, other) = os.path.split(this_dir) test_functions.set_path_to_tests(path_to_tests) if not os.path.isdir('temp'): os.mkdir('temp') fail = 0 fail = testSedML(fail) fail = testCombine(fail) test_functions.report('OTHER LIBRARY', fail, fails, not_tested) return fail
def main(): # set up the enivornment this_dir = os.path.dirname(os.path.abspath(__file__)) (path_to_tests, other) = os.path.split(this_dir) test_functions.set_path_to_tests(path_to_tests) if not os.path.isdir('temp'): os.mkdir('temp') fail = 0 # run the individual tests name = 'qual' fail += run_test(name) name = 'lo_children' fail += run_test(name) name = 'lo_children' fail += run_xml_test(name) name = 'base_class' fail += run_xml_test(name) name = 'base_class' fail += run_xml_fail_tests(name) name = 'groups' fail += run_xml_test(name) name = 'groups' fail += run_xml_fail_tests(name) name = 'qual' fail += run_xml_test(name) # write summary test_functions.report('examples', fail, fails, not_tested) return fail
def main(): # NB the reference files in test-code/ and test-extension/ were # presumably generated on Windows. I am running these tests on a # MacBook (so like Linux). The file comparison works OK for # Python 3 but not Python 2. I ran all the reference files through # dos2unix and now all the tests work under Python 2 unless noted below. runall = True # runall = False this_dir = os.path.dirname(os.path.abspath(__file__)) (path_to_tests, other) = os.path.split(this_dir) test_functions.set_path_to_tests(path_to_tests) if not os.path.isdir('temp'): os.mkdir('temp') fail = 0 # Run the next couple of tests always: name = 'copy' num = 0 class_name = 'Def' list_of = '' test_case = 'class with XMLNode' fail += run_test(name, num, class_name, test_case, list_of) name = 'copy_add' num = 0 class_name = 'Abc' list_of = '' test_case = 'class with additional code' fail += run_test(name, num, class_name, test_case, list_of) if runall: # run the individual tests name = 'test_att' num = 1 class_name = 'Unit' list_of = '' test_case = 'unit sid ref' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 2 class_name = 'MyLoTest' list_of = 'ListOfMyLoTests' test_case = 'attribute on ListOf' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 0 class_name = 'MyTestClass' list_of = '' test_case = 'all types of attributes' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 3 class_name = 'MyRequiredClass' list_of = '' test_case = 'all types attributes required' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 4 class_name = 'ArrayChild' list_of = '' test_case = 'child elements and arrays' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 5 class_name = 'Container' list_of = '' test_case = 'a listOf child that uses listOfFoo as the name' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' class_name = 'TestSBMLError' test_case = 'error enumeration' fail += run_valid_test(name, class_name, test_case) name = 'qual' num = 5 class_name = 'FunctionTerm' list_of = 'ListOfFunctionTerms' test_case = 'an element on ListOf' fail += run_test(name, num, class_name, test_case, list_of) name = 'qual' num = 3 class_name = 'Output' list_of = 'ListOfOutputs' test_case = 'simple class' fail += run_test(name, num, class_name, test_case, list_of) name = 'qual' num = 1 class_name = 'Transition' list_of = 'ListOfTransitions' test_case = 'class with child list of elements' fail += run_test(name, num, class_name, test_case, list_of) name = 'qual' class_name = 'QualExtension' test_case = 'basic extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'qual' num = 0 class_name = 'QualModelPlugin' test_case = 'basic plugin' fail += run_plug_test(name, class_name, test_case, num) name = 'qual' class_name = 'QualExtensionTypes' test_case = 'the types ' fail += run_ext_test(name, class_name, test_case, 1) name = 'qual' class_name = 'qualfwd' test_case = 'forward declarations' fail += run_ext_test(name, class_name, test_case, 2) name = 'qual' num = 1 class_name = 'QualSBMLDocumentPlugin' test_case = 'document plugin' fail += run_plug_test(name, class_name, test_case, num) name = 'qual' class_name = 'QualSBMLError' test_case = 'error enumeration' fail += run_valid_test(name, class_name, test_case) name = 'qual' class_name = 'QualConsistencyValidator' test_case = 'validator' fail += run_valid_test(name, class_name, test_case, False) name = 'qual' class_name = 'QualValidator' test_case = 'validator' fail += run_valid_test(name, class_name, test_case, False) name = 'distrib' num = 2 class_name = 'UncertaintyOld' list_of = '' test_case = 'class with other child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 7 class_name = 'CoordinateComponent' list_of = 'ListOfCoordinateComponents' test_case = 'class with same child element diff name' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 15 class_name = 'CSGeometry' list_of = '' test_case = 'abstract' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 17 class_name = 'CSGNode' list_of = 'ListOfCSGNodes' test_case = 'abstract' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 16 class_name = 'CSGObject' list_of = '' test_case = 'abstract children' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 33 class_name = 'SpatialPoints' list_of = '' test_case = 'array type' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 8 class_name = 'SampledFieldGeometry' list_of = '' test_case = 'non sbase base class' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 9 class_name = 'SampledField' list_of = '' test_case = 'additional code files' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 18 class_name = 'CSGTransformation' list_of = '' test_case = 'abstract non base class' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 3 class_name = 'Boundary' list_of = '' test_case = 'overwrites element name' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 13 class_name = 'ParametricGeometry' list_of = '' test_case = 'child element and child lo_element' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 12 class_name = 'AnalyticVolume' list_of = 'ListOfAnalyticVolumes' test_case = 'class with math child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 5 class_name = 'GeometryDefinition' list_of = 'ListOfGeometryDefinitions' test_case = 'class with math child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 30 class_name = 'Geometry' list_of = '' test_case = 'class with math child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 31 class_name = 'MixedGeometry' list_of = '' test_case = 'class with math child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 25 class_name = 'CSGSetOperator' list_of = '' test_case = 'contains list of that has abstracts that are abstract' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 1 class_name = 'SpatialCompartmentPlugin' test_case = 'plugin with child element' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' num = 3 class_name = 'SpatialParameterPlugin' test_case = 'plugin with additional code' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' num = 4 class_name = 'SpatialReactionPlugin' test_case = 'plugin only attributes' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' num = 5 class_name = 'SpatialSBMLDocumentPlugin' test_case = 'include line over extends' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' class_name = 'SpatialConsistencyConstraints' test_case = 'constraints' fail += run_constraints_test(name, class_name, test_case) name = 'spatial' class_name = 'SpatialValidator' test_case = 'validator' fail += run_valid_test(name, class_name, test_case, False) name = 'groups' num = 1 class_name = 'Member' list_of = 'ListOfMembers' test_case = 'list of with attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'groups' num = 0 class_name = 'Group' list_of = 'ListOfGroups' test_case = 'list of with attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'groups' num = 0 class_name = 'GroupsModelPlugin' test_case = 'plugin with additional code' fail += run_plug_test(name, class_name, test_case, num) name = 'groups' class_name = 'GroupsExtension' test_case = 'basic extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'groups' num = 1 class_name = 'GroupsSBMLDocumentPlugin' test_case = 'basic plugin' fail += run_plug_test(name, class_name, test_case, num) name = 'groups' class_name = 'GroupsSBMLError' test_case = 'error enumeration' fail += run_valid_test(name, class_name, test_case) name = 'test_vers' num = 0 class_name = 'ClassOne' list_of = '' test_case = 'multiple versions' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_vers' num = 2 class_name = 'BBB' list_of = '' test_case = 'multiple versions same child lo' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_vers' num = 0 class_name = 'VersModelPlugin' test_case = 'versions of plugins - attributes' fail += run_plug_test(name, class_name, test_case, num) name = 'test_vers' num = 1 class_name = 'VersSpeciesPlugin' test_case = 'versions of plugins - elements' fail += run_plug_test(name, class_name, test_case, num) name = 'test_vers' class_name = 'VersExtension' test_case = 'multi version extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'fbc_v2' num = 1 class_name = 'Objective' list_of = 'ListOfObjectives' test_case = 'lo_element with attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'fbc_v2' num = 5 class_name = 'FbcAnd' list_of = '' test_case = 'inline_lo_element' fail += run_test(name, num, class_name, test_case, list_of) name = 'fbc_v2' num = 7 class_name = 'Association' list_of = 'ListOfAssociations' test_case = 'lo_element with abstract children' fail += run_test(name, num, class_name, test_case, list_of) name = 'fbc_v2' class_name = 'FbcSBMLError' test_case = 'error enumeration' fail += run_valid_test(name, class_name, test_case) name = 'fbc_v2' num = 0 class_name = 'FbcModelPlugin' test_case = 'plugin with attributes' fail += run_plug_test(name, class_name, test_case, num) name = 'test_child' num = 0 class_name = 'MySEDClass' list_of = '' test_case = 'different language' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' num = 0 class_name = 'MyBase' list_of = '' test_case = 'class with no given base class' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' num = 1 class_name = 'ClassTwo' list_of = 'ListOfClassTwos' test_case = 'class with lower case name' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' num = 2 class_name = 'ClassThree' list_of = '' test_case = 'class with enum lower case name' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' class_name = 'TestExtension' test_case = 'default typecodes extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'unknown_type' num = 0 class_name = 'UnknownType' list_of = '' test_case = 'class using an unknown attribute type' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_sidrefs' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets' fail += run_valid_test(name, class_name, test_case) # These next tests are testing the spacing of the element content # eg. # element="ThingA, ThingB" # element=" ThingA, ThingB" # element="ThingA,ThingB" name = 'test_sidrefs_1' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_sidrefs_2' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_sidrefs_3' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_sidrefs_4' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_lists' class_name = 'FooSBMLError' test_case = 'error enumeration' fail += run_valid_test(name, class_name, test_case) name = 'nasty_lists' num = 0 class_name = 'Child' list_of = '' test_case = 'non uniform listOf name' fail += run_test(name, num, class_name, test_case, list_of) name = 'nasty_lists' num = 2 class_name = 'Parent' list_of = '' test_case = 'non uniform listOf name' fail += run_test(name, num, class_name, test_case, list_of) name = 'nasty_lists_alt1' num = 2 class_name = 'Parent' list_of = '' test_case = 'non uniform listOf name' fail += run_test(name, num, class_name, test_case, list_of) name = 'lo_children' num = 1 class_name = 'ContainerX' list_of = '' test_case = 'variants of lo child elements and differing api/xml names' fail += run_test(name, num, class_name, test_case, list_of) name = 'xml_names' num = 0 class_name = 'Fred' list_of = '' test_case = 'attribute xml names differ' fail += run_test(name, num, class_name, test_case, list_of) name = 'xml_names' num = 1 class_name = 'Other' list_of = '' test_case = 'element xml names differ' fail += run_test(name, num, class_name, test_case, list_of) name = 'add_copyright' num = 0 class_name = 'Copyright' list_of = '' test_case = 'additional copyright' fail += run_test(name, num, class_name, test_case, list_of) name = 'core' num = 0 class_name = 'Compartment' list_of = '' test_case = 'new attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'core' num = 14 class_name = 'ModifierSpeciesReference' list_of = '' test_case = 'new attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'core' num = 22 class_name = 'Event' list_of = '' test_case = 'new element functions' fail += run_test(name, num, class_name, test_case, list_of) name = 'core' num = 11 class_name = 'Constraint' list_of = '' test_case = 'has XML Node child' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 2 class_name = 'Distribution' list_of = '' test_case = 'abstract class with multiple abstract children' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 0 class_name = 'DrawFromDistribution' list_of = '' test_case = 'abstract class with multiple abstract children' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 6 class_name = 'DiscreteUnivariateDistribution' list_of = '' test_case = 'abstract class with multiple abstract children' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 15 class_name = 'BernoulliDistribution' list_of = '' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 14 class_name = 'Category' list_of = 'ListOfCategories' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 13 class_name = 'CategoricalDistribution' list_of = '' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 16 class_name = 'BetaDistribution' list_of = '' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 23 class_name = 'ExponentialDistribution' list_of = '' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 17 class_name = 'BinomialDistribution' list_of = '' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' num = 21 class_name = 'Uncertainty' list_of = '' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'new_distrib' class_name = 'DistribSBMLError' test_case = 'error enumeration' fail += run_valid_test(name, class_name, test_case) name = 'new_distrib' num = 11 class_name = 'ExternalParameter' list_of = '' test_case = 'class contains a listOf itself' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_core_vers' class_name = 'CoreversExtension' test_case = 'core version extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'test_core_vers_pkg' class_name = 'CoreversPkgExtension' test_case = 'core version and package version not 1 extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'test_core_vers_multipkg' num = 0 class_name = 'ClassOneTwo' list_of = '' test_case = 'core version and package version not 1' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_core_vers_multipkg' class_name = 'CoreversMultiPkgExtension' test_case = 'multiple core version and package version not 1 extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'test_core_vers_multipkg' num = 0 class_name = 'CoreversMultiPkgModelPlugin' test_case = 'versions of plugins - elements' fail += run_plug_test(name, class_name, test_case, num) name = 'twoAtOnce' num = 0 class_name = 'TwoatonceSBasePlugin' test_case = 'an SBase plugin' fail += run_plug_test(name, class_name, test_case, num) name = 'twoAtOnce' class_name = 'TwoatonceExtension' test_case = 'basic extension file with SBasePlugin' fail += run_ext_test(name, class_name, test_case, 0) name = 'twoAtOnce' num = 1 class_name = 'ClassWithRequiredID' list_of = '' test_case = 'concrete class' fail += run_test(name, num, class_name, test_case, list_of) name = 'twoAtOnce' num = 3 class_name = 'MultipleChild' list_of = '' test_case = 'multiple versions with child elements' fail += run_test(name, num, class_name, test_case, list_of) # leave out for now as all validation needs reviewing for multiple name = 'twoAtOnce' class_name = 'TwoAtOnceSBMLError' test_case = 'error enumeration' # fail += run_valid_test(name, class_name, test_case) # leave out as need to work on automatically adding prefix # name = 'new_distrib_test' # num = 36 # class_name = 'DistribUncertainty' # list_of = '' # test_case = 'concrete class' # fail += run_test(name, num, class_name, test_case, list_of) # # name = 'new_distrib_test' # num = 16 # class_name = 'DistribBernoulliDistribution' # list_of = '' # test_case = 'concrete class' # fail += run_test(name, num, class_name, test_case, list_of) # # name = 'new_distrib_test' # num = 14 # class_name = 'DistribCategoricalDistribution' # list_of = '' # test_case = 'concrete class' # fail += run_test(name, num, class_name, test_case, list_of) name = 'plugin_id' num = 0 class_name = 'PluginidSBasePlugin' test_case = 'an SBase plugin' fail += run_plug_test(name, class_name, test_case, num) name = 'render' num = 5 class_name = 'GradientStop' list_of = '' test_case = 'hyphenated attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'render' num = 12 class_name = 'Polygon' list_of = '' test_case = 'list of with different types elements' fail += run_test(name, num, class_name, test_case, list_of) name = 'render' class_name = 'RenderSBMLError' test_case = 'error enumeration' fail += run_valid_test(name, class_name, test_case) name = 'render' num = 23 class_name = 'GraphicalPrimitive2D' list_of = '' test_case = 'hyphenated enum attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'render' num = 26 class_name = 'DefaultValues' list_of = '' test_case = 'hyphenated attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'render' num = 6 class_name = 'RenderGroup' list_of = '' test_case = 'very nested base' fail += run_test(name, num, class_name, test_case, list_of) name = 'render' num = 8 class_name = 'LineEnding' list_of = '' test_case = 'uses other package class' fail += run_test(name, num, class_name, test_case, list_of) name = 'multi' class_name = 'MultiExtension' test_case = 'basic extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'multi' num = 4 class_name = 'OutwardBindingSite' list_of = '' test_case = 'spacing of refs' fail += run_test(name, num, class_name, test_case, list_of) name = 'comp' num = 3 class_name = 'CompSBMLDocumentPlugin' test_case = 'document plugin with additional items' fail += run_plug_test(name, class_name, test_case, num) name = 'sbgn' num = 3 class_name = 'Map' list_of = '' test_case = 'list of with different types elements' fail += run_test(name, num, class_name, test_case, list_of) name = 'sbgn' num = 7 class_name = 'Arc' list_of = '' test_case = 'list of with different types elements' fail += run_test(name, num, class_name, test_case, list_of) name = 'sbgn' num = 2 class_name = 'Label' list_of = '' test_case = 'element with different xml name' fail += run_test(name, num, class_name, test_case, list_of) name = 'sbgn' num = 0 class_name = 'Point' list_of = 'SbgnListOfPoints' test_case = 'contains list of itself but with other listof used elsewhere' fail += run_test(name, num, class_name, test_case, list_of) # not yet sorted # name = 'arrays' # class_name = 'ArraysExtensionTypes' # test_case = 'the types ' # fail += run_ext_test(name, class_name, test_case, 1) # # name = 'arrays' # class_name = 'ArraysExtension' # test_case = 'basic extension file' # fail += run_ext_test(name, class_name, test_case, 0) # # name = 'arrays' # num = 1 # class_name = 'Index' # list_of = 'ListOfIndices' # test_case = 'list of with attribute' # fail += run_test(name, num, class_name, test_case, list_of) # # name = 'arrays' # class_name = 'ArraysValidator' # test_case = 'validator' # fail += run_valid_test(name, class_name, test_case, False) else: pass test_functions.report('CPP', fail, fails, not_tested) return fail
def main(): # set up the enivornment this_dir = os.path.dirname(os.path.abspath(__file__)) (path_to_tests, other) = os.path.split(this_dir) test_functions.set_path_to_tests(path_to_tests) if not os.path.isdir('temp'): os.mkdir('temp') fail = 0 # run the individual tests name = 'test_att' num = 1 class_name = 'Unit' list_of = '' test_case = 'unit sid ref' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 2 class_name = 'MyLoTest' list_of = 'ListOfMyLoTests' test_case = 'attribute on ListOf' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 0 class_name = 'MyTestClass' list_of = '' test_case = 'all types of attributes' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 3 class_name = 'MyRequiredClass' list_of = '' test_case = 'all types attributes required' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 4 class_name = 'ArrayChild' list_of = '' test_case = 'child elements and arrays' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' num = 5 class_name = 'Container' list_of = '' test_case = 'a listOf child that uses listOfFoo as the name' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_att' class_name = 'TestSBMLError' test_case = 'error enumeration ' fail += run_valid_test(name, class_name, test_case) name = 'qual' num = 5 class_name = 'FunctionTerm' list_of = 'ListOfFunctionTerms' test_case = 'an element on ListOf' fail += run_test(name, num, class_name, test_case, list_of) name = 'qual' num = 3 class_name = 'Output' list_of = 'ListOfOutputs' test_case = 'simple class' fail += run_test(name, num, class_name, test_case, list_of) name = 'qual' num = 1 class_name = 'Transition' list_of = 'ListOfTransitions' test_case = 'class with child list of elements' fail += run_test(name, num, class_name, test_case, list_of) name = 'qual' class_name = 'QualExtension' test_case = 'basic extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'qual' num = 0 class_name = 'QualModelPlugin' test_case = 'basic plugin' fail += run_plug_test(name, class_name, test_case, num) name = 'qual' class_name = 'QualExtensionTypes' test_case = 'the types ' fail += run_ext_test(name, class_name, test_case, 1) name = 'qual' class_name = 'qualfwd' test_case = 'forward declarations ' fail += run_ext_test(name, class_name, test_case, 2) name = 'qual' num = 1 class_name = 'QualSBMLDocumentPlugin' test_case = 'document plugin' fail += run_plug_test(name, class_name, test_case, num) name = 'qual' class_name = 'QualSBMLError' test_case = 'error enumeration ' fail += run_valid_test(name, class_name, test_case) name = 'qual' class_name = 'QualConsistencyValidator' test_case = 'validator' fail += run_valid_test(name, class_name, test_case, False) name = 'distrib' num = 2 class_name = 'Uncertainty' list_of = '' test_case = 'class with other child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 7 class_name = 'CoordinateComponent' list_of = 'ListOfCoordinateComponents' test_case = 'class with same child element diff name' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 17 class_name = 'CSGNode' list_of = 'ListOfCSGNodes' test_case = 'abstract' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 35 class_name = 'SpatialPoints' list_of = '' test_case = 'array type' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 8 class_name = 'SampledFieldGeometry' list_of = '' test_case = 'non sbase base class' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 9 class_name = 'SampledField' list_of = '' test_case = 'additional code files' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 18 class_name = 'CSGTransformation' list_of = '' test_case = 'abstract non base class' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 3 class_name = 'Boundary' list_of = '' test_case = 'overwrites element name' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 13 class_name = 'ParametricGeometry' list_of = '' test_case = 'child element and child lo_element' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 12 class_name = 'AnalyticVolume' list_of = 'ListOfAnalyticVolumes' test_case = 'class with math child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 33 class_name = 'MixedGeometry' list_of = '' test_case = 'class with math child' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 26 class_name = 'CSGSetOperator' list_of = '' test_case = 'contains list of that has abstracts that are abstract' fail += run_test(name, num, class_name, test_case, list_of) name = 'spatial' num = 1 class_name = 'SpatialCompartmentPlugin' test_case = 'plugin with child element' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' num = 3 class_name = 'SpatialParameterPlugin' test_case = 'plugin with additional code' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' num = 4 class_name = 'SpatialReactionPlugin' test_case = 'plugin only attributes' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' num = 5 class_name = 'SpatialSBMLDocumentPlugin' test_case = 'include line over extends' fail += run_plug_test(name, class_name, test_case, num) name = 'spatial' class_name = 'SpatialConsistencyConstraints' test_case = 'constraints' fail += run_constraints_test(name, class_name, test_case) name = 'spatial' class_name = 'SpatialValidator' test_case = 'validator' fail += run_valid_test(name, class_name, test_case, False) name = 'groups' num = 1 class_name = 'Member' list_of = 'ListOfMembers' test_case = 'list of with attribute' fail += run_test(name, num, class_name, test_case, list_of) name = 'groups' num = 0 class_name = 'GroupsModelPlugin' test_case = 'plugin with additional code' fail += run_plug_test(name, class_name, test_case, num) name = 'test_vers' num = 0 class_name = 'ClassOne' list_of = '' test_case = 'multiple versions' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_vers' num = 2 class_name = 'BBB' list_of = '' test_case = 'multiple versions same child lo' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_vers' num = 0 class_name = 'VersModelPlugin' test_case = 'versions of plugins - attributes' fail += run_plug_test(name, class_name, test_case, num) name = 'test_vers' num = 1 class_name = 'VersSpeciesPlugin' test_case = 'versions of plugins - elements' fail += run_plug_test(name, class_name, test_case, num) name = 'test_vers' class_name = 'VersExtension' test_case = 'multi version extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'fbc_v2' num = 5 class_name = 'FbcAnd' list_of = '' test_case = 'inline_lo_element' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_child' num = 0 class_name = 'MySEDClass' list_of = '' test_case = 'different language' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' num = 0 class_name = 'MyBase' list_of = '' test_case = 'class with no given base class' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' num = 1 class_name = 'ClassTwo' list_of = 'ListOfClassTwos' test_case = 'class with lower case name' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' num = 2 class_name = 'ClassThree' list_of = '' test_case = 'class with enum lower case name' fail += run_test(name, num, class_name, test_case, list_of) name = 'base_class' class_name = 'TestExtension' test_case = 'default typecodes extension file' fail += run_ext_test(name, class_name, test_case, 0) name = 'unknown_type' num = 0 class_name = 'UnknownType' list_of = '' test_case = 'class using an unknown attribute type' fail += run_test(name, num, class_name, test_case, list_of) name = 'test_sidrefs' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets ' fail += run_valid_test(name, class_name, test_case) name = 'test_sidrefs_1' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_sidrefs_2' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_sidrefs_3' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_sidrefs_4' class_name = 'RefsSBMLError' test_case = 'sidref with multiple targets - diff spacing' fail += run_valid_test(name, class_name, test_case) name = 'test_lists' class_name = 'FooSBMLError' test_case = 'error enumeration ' fail += run_valid_test(name, class_name, test_case) name = 'nasty_lists' num = 0 class_name = 'Child' list_of = '' test_case = 'non uniform listOf name' fail += run_test(name, num, class_name, test_case, list_of) name = 'nasty_lists' num = 2 class_name = 'Parent' list_of = '' test_case = 'non uniform listOf name' fail += run_test(name, num, class_name, test_case, list_of) name = 'nasty_lists_alt1' num = 2 class_name = 'Parent' list_of = '' test_case = 'non uniform listOf name' fail += run_test(name, num, class_name, test_case, list_of) name = 'lo_children' num = 1 class_name = 'ContainerX' list_of = '' test_case = 'variants of lo child elements and differing api/xml names' fail += run_test(name, num, class_name, test_case, list_of) name = 'xml_names' num = 0 class_name = 'Fred' list_of = '' test_case = 'attribute xml names differ' fail += run_test(name, num, class_name, test_case, list_of) name = 'xml_names' num = 1 class_name = 'Other' list_of = '' test_case = 'element xml names differ' fail += run_test(name, num, class_name, test_case, list_of) name = 'add_copyright' num = 0 class_name = 'Copyright' list_of = '' test_case = 'additional copyright' fail += run_test(name, num, class_name, test_case, list_of) test_functions.report('CPP', fail, fails, not_tested) return fail
def main(): # NOTE: the test sets below are in the same order as the functions # appear in strFunctions.py. Please maintain that. Thanks. # Set up variables fails = [] not_tested = [] fail = 0 ####################################################### # Start of tests # upper_first() tests fail += run_strfunc_test(sf.upper_first, 'cat', 'Cat', fails) # fail += run_strfunc_test(sf.upper_first, 'cat', 'CAT') # A failure test data = {'cat': 'Cat', 'csgsomething': 'CSGsomething', 'csgcat': 'CSGcat', 'cscat': 'Cscat', 'csgeometry': 'CSGeometry', 'csGeometry': 'CSGeometry', 'a': 'A'} fail += execute_tests(sf.upper_first, data, fails) # lower_first() tests - it's virtually the exact opposite of upper_first() data2 = swap_dictionary(data) fail += execute_tests(sf.lower_first, data2, fails) # abbrev_name() tests data = {"thisIsATest": "iat", "CAT": "cat", "cat": "c", "c": "c", "C": "c"} fail += execute_tests(sf.abbrev_name, data, fails) # abbrev_lo_name() tests data = {"spaghetti": "", "ListOfFoo": "LOFoo", "ListOfFOO": "LOFOO"} fail += execute_tests(sf.abbrev_lo_name, data, fails) # list_of_name() tests gv.reset() data = {"FooParameter": "ListOfFooParameters"} fail += execute_tests(sf.list_of_name, data, fails, add_prefix=True) fail += execute_tests(sf.list_of_name, data, fails, add_prefix=False) # print(f"gv is package: {gv.is_package}, gv prefix: {gv.prefix}") gv.is_package = False fail += execute_tests(sf.list_of_name, data, fails, add_prefix=False) data = {"FooParameter": "SBMLListOfFooParameters"} fail += execute_tests(sf.list_of_name, data, fails, add_prefix=True) # lower_list_of_name_no_prefix() tests gv.reset() data = {"fox": "listOfFoxes", "cat": "listOfCats", "child": "listOfChildren"} fail += execute_tests(sf.lower_list_of_name_no_prefix, data, fails) gv.is_package = False fail += execute_tests(sf.lower_list_of_name_no_prefix, data, fails) # cap_list_of_name() tests gv.reset() data = {"FooParameter": "ListOfFooParameters", "cat": "ListOfCats"} fail += execute_tests(sf.cap_list_of_name, data, fails, add_prefix=False) fail += execute_tests(sf.cap_list_of_name, data, fails, add_prefix=True) gv.is_package = False fail += execute_tests(sf.cap_list_of_name, data, fails, add_prefix=False) data = {"FooParameter": "SBMLListOfFooParameters", "cat": "SBMLListOfCats"} fail += execute_tests(sf.cap_list_of_name, data, fails, add_prefix=True) # cap_list_of_name_no_prefix() tests gv.reset() data = {"FooParameter": "ListOfFooParameters", "cat": "ListOfCats", "SBMLFooParameter": "ListOfSBMLFooParameters"} fail += execute_tests(sf.cap_list_of_name_no_prefix, data, fails) gv.is_package = False # this gets wrongly dealt with by the remove prefix function # TODO sort data = {"FooParameter": "ListOfFooParameters", "cat": "ListOfCats", "SBMLFooParameter": "ListOfFooParameters"} # fail += execute_tests(sf.cap_list_of_name_no_prefix, data, fails) # plural_no_prefix() tests gv.reset() data = {"fox": "foxes", "child": "children", "SBMLchild": "SBMLchildren"} fail += execute_tests(sf.plural_no_prefix, data, fails) gv.is_package = False gv.prefix = "Rosie" data = {"RosieFox": "Foxes", "RosieChild": "Children", "RosieCat": "Cats", "Rosiefox": "Rosiefoxes"} # prefix only removed if capital after fail += execute_tests(sf.plural_no_prefix, data, fails) gv.is_package = True data = {"Rosiefox": "Rosiefoxes", "Rosiechild": "Rosiechildren", "RosieCat": "RosieCats"} fail += execute_tests(sf.plural_no_prefix, data, fails) # plural() tests data = {"cat": "cats", "dogs": "dogs", "child": "children", "disinformation": "disinformation", "fox": "foxes", "party": "parties", "cloud": "clouds", "something": "somethings", "apple": "apples"} fail += execute_tests(sf.plural, data, fails) # singular() tests data2 = swap_dictionary(data) data2['dogs'] = 'dog' # Just need to tweak this one entry. Otherwise OK. fail += execute_tests(sf.singular, data2, fails) # single -> plural -> single data = {"cat": "cat", "dog": "dog", "child": "child", "disinformation": "disinformation", "fox": "fox", "party": "party", "cloud": "cloud", "something": "something", "apple": "apple"} fail += execute_tests(plural_then_single, data, fails) data = {"cats": "cats", "dogs": "dogs", "children": "children", "disinformation": "disinformation", "foxes": "foxes", "parties": "parties", "clouds": "clouds", "somethings": "somethings", "apples": "apples"} fail += execute_tests(single_then_plural, data, fails) # remove_prefix() tests - this is a complicated function to test! # tests removing a package prefix gv.reset() # gv.prefix now "SBML" gv.is_package = True gv.package_prefix = 'Fbc' data = {"FbcType": "Type", "FluxObjective": "FluxObjective", "FbcSBMLDocument": "FbcSBMLDocument"} fail += execute_tests(sf.remove_prefix, data, fails) fail += execute_tests(sf.remove_prefix, data, fails, remove_package=True) doc_data = {"FbcSBMLDocument": "SBMLDocument"} fail += execute_tests(sf.remove_prefix, doc_data, fails, remove_doc_prefix=True) gv.reset() # gv.prefix now "SBML" gv.is_package = True gv.package_prefix = '' # package prefix has not been specified fail += execute_tests(sf.remove_prefix, data, fails, prefix='Fbc') # no prefix to remove has been specified or explicitly told not to remove data = {"FbcType": "FbcType", "FluxObjective": "FluxObjective", "FbcSBMLDocument": "FbcSBMLDocument"} fail += execute_tests(sf.remove_prefix, data, fails, prefix='') fail += execute_tests(sf.remove_prefix, data, fails, prefix='Fbc', remove_package=False) fail += execute_tests(sf.remove_prefix, data, fails, remove_doc_prefix=True) fail += execute_tests(sf.remove_prefix, data, fails, prefix='', remove_doc_prefix=True) fail += execute_tests(sf.remove_prefix, data, fails, prefix='Fbc', remove_doc_prefix=False, remove_package=False) doc_data = {"FbcSBMLDocument": "SBMLDocument"} fail += execute_tests(sf.remove_prefix, doc_data, fails, prefix='Fbc', remove_doc_prefix=True) gv.reset() # gv.prefix now "SBML" gv.prefix = "Rosie" gv.is_package = False data = {"RosieFbcType": "FbcType", "RosieDocument": "RosieDocument"} fail += execute_tests(sf.remove_prefix, data, fails, prefix='Rosie') data_doc = {"RosieFbcType": "FbcType", "RosieDocument": "Document"} fail += execute_tests(sf.remove_prefix, data_doc, fails, prefix='Rosie', remove_doc_prefix=True) gv.reset() # gv.prefix now "SBML" data = {} # is_prefixed_name_test data = {"RosieFox": True, "rosieFoo": True, "rosiefoo": False, "RosiFox": False, "RoSiEFoo": True, "RoSiEfoo": False} fail += execute_tests(sf.is_prefixed_name, data, fails, prefix='Rosie') # is_prefixed_document_class test data = {"RosieDocument": True, "rosieDocument": True, "rosiedocument": False, "RosiDocument": False, "RoSiEDocument": True, "RoSiEDocment": False} fail += execute_tests(sf.is_prefixed_document_class, data, fails, prefix='Rosie') # get_indefinite() tests data = {"apple": "an", "biscuit": "a", "elephant": "an", "image": "an", "polar bear": "a", "orangutan": "an", "under secretary": "an", "zither": "a"} fail += execute_tests(sf.get_indefinite, data, fails) # standard_element_name() tests data = {"listOfFoxes,": "Fox", "ListOfApples": "Apple", "XMLNode*": "XMLNode", "Rosie,": "Rosie", "rosie,": "Rosie", "name_t": "Name", "Name": "Name", "name": "Name"} fail += execute_tests(sf.standard_element_name, data, fails) # get_library_suffix() tests data = {"library": "Rary", "libSBML": "Sbml", "cat": "Cat", "lib": ""} fail += execute_tests(sf.get_library_suffix, data, fails) # A varargs example - wrap_token fail += run_strfunc_test(sf.wrap_token, 'fred', '\\token{cat:\\-fred}', fails, pkg='cat') fail += run_strfunc_test(sf.wrap_token, 'fred', '\\token{fred}', fails) # wrap_type() tests - I don't really understand this one! # wrap_section() tests - or this one! # make_class() tests fail += run_strfunc_test(sf.make_class, 'Irenaeus', 'irenaeus-class', fails) fail += run_strfunc_test(sf.make_class, 'Irenaeus', 'extended-irenaeus-class', fails, add_extended=True) # wrap_enum() tests fail += run_strfunc_test(sf.wrap_enum, 'cat', '\\primtype{cat}', fails) # get_sid_refs() tests 'cat': 'Cat', 'csgsomething': 'CSGsomething', data = {'': ['', 'SId'], 'cat': ['Cat', 'Cat'], 'csgsomething': ['CSGsomething', 'CSGsomething'], 'cat,dog': ["Cat or \\Dog", "CatOrDog"]} fail += execute_tests(sf.get_sid_refs, data, fails) # get_element_name() tests gv.reset() gv.prefix = 'Bar' gv.is_package = False attribute1 = {'something': 'something else'} attribute2 = {'type': 'element', 'element': 'ASTNode*', 'texname': 'tex'} attribute3 = {'isListOf': True, 'name': 'Foo'} attribute4 = {'type': 'element', 'element': 'Unit', 'texname': 'Unit'} attribute5 = {'type': 'lo_element', 'element': 'Unit', 'texname': 'Unit'} attribute6 = {'type': 'double', 'element': 'Unit', 'texname': 'Unit'} attribute7 = {'isListOf': False, 'name': 'Foo'} attribute8 = {'type': 'lo_element', 'element': 'Unit', 'name': 'Unit', 'listOfClassName': 'ListOfAnything'} fail += run_strfunc_test(sf.get_element_name, attribute1, "FIX_ME", fails) fail += run_strfunc_test(sf.get_element_name, attribute2, "MathML math", fails) fail += run_strfunc_test(sf.get_element_name, attribute3, "\\BarListOfFoos", fails) fail += run_strfunc_test(sf.get_element_name, attribute4, "Unit", fails) fail += run_strfunc_test(sf.get_element_name, attribute5, "\\BarListOfUnits", fails) fail += run_strfunc_test(sf.get_element_name, attribute5, "\\ListOfUnits", fails, add_prefix_if_not_pkg=False) fail += run_strfunc_test(sf.get_element_name, attribute5, "\\ListOfUnits", fails, leave_pkg_prefix=False) fail += run_strfunc_test(sf.get_element_name, attribute6, "FIX_ME", fails) fail += run_strfunc_test(sf.get_element_name, attribute7, "\\Foo", fails) fail += run_strfunc_test(sf.get_element_name, attribute8, "\\BarListOfUnits", fails) fail += run_strfunc_test(sf.get_element_name, attribute8, "\\ListOfAnything", fails, leave_pkg_prefix=False) gv.reset() gv.prefix = 'Bar' gv.is_package = True gv.package_prefix = 'Foo' attribute1 = {'type': 'lo_element', 'element': 'Unit', 'name': 'FooUnit', 'isListOf': True} attribute2 = {'type': 'lo_element', 'element': 'Unit', 'name': 'Unit', 'isListOf': True, 'listOfClassName': 'ListOfUnits'} fail += run_strfunc_test(sf.get_element_name, attribute1, "\\ListOfFooUnits", fails) fail += run_strfunc_test(sf.get_element_name, attribute1, "\\ListOfFooUnits", fails, add_prefix_if_not_pkg=False) fail += run_strfunc_test(sf.get_element_name, attribute2, "\\ListOfUnits", fails) fail += run_strfunc_test(sf.get_element_name, attribute2, "\\ListOfUnits", fails, leave_pkg_prefix=False) fail += run_strfunc_test(sf.get_element_name, attribute2, "\\ListOfUnits", fails, add_prefix_if_not_pkg=False) # replace_digits() tests fail += run_strfunc_test(sf.replace_digits, "John 3:16", "John Three:OneSix", fails) # replace_underscore() tests data = {"this_is_a_test": "this\\_is\\_a\\_test", "cat": "cat", "_": "\\_"} fail += execute_tests(sf.replace_underscore, data, fails) # remove_spaces() tests data = {" hello world ": "helloworld", "dogfish": "dogfish"} fail += execute_tests(sf.remove_spaces, data, fails) # remove_hyphens() tests data = {"this-is-a-test": ["thisIsATest", True], "cat": ["cat", False], "cat-": ["cat", True], "-cat": ["Cat", True]} fail += execute_tests(sf.remove_hyphens, data, fails) # texify() tests fail += run_strfunc_test(sf.texify, "012_27 cat44_8 ", "ZeroOneTwo\\_TwoSevencatFourFour\\_Eight", fails) # compare_no_case() tests fail += run_strfunc_test(sf.compare_no_case, "This iS a TEST", True, fails, reference="this is a test") fail += run_strfunc_test(sf.compare_no_case, "This iS a bad TEST", False, fails, reference="this is a test") # get_class_from_plugin() tests fail += run_strfunc_test(sf.get_class_from_plugin, "CompModelPlugin", "Model", fails, package="Comp") fail += run_strfunc_test(sf.get_class_from_plugin, "CompModelPlug", "", fails, package="Comp") fail += run_strfunc_test(sf.get_class_from_plugin, "Plugin", "", fails, package="Comp") # prefix_name() tests gv.reset() gv.prefix = "DABS" data = {"DABS": "DABS", "DABSCAT": "DABSCAT", "dabs": "DABSdabs", "SBase": "DABSBase", "XMLNode": "XMLNode", "XMLNodeAgain": "DABSXMLNodeAgain", "ASTNode": "ASTNode"} fail += execute_tests(sf.prefix_name, data, fails) # prefix_classes() tests # This func doesn't return anything at the moment. So we have to # compare "changing" dictionary with what we expect it to be once # it's changed. gv.reset() # gv.prefix is now "SBML" changing_dict = {'name': 'Colin', 'baseClass': gv.baseClass} expected_dict = {'name': 'SBMLColin', 'baseClass': gv.baseClass, 'elementName': 'colin'} # Do not consume return value run_strfunc_test(sf.prefix_classes, changing_dict, None, fails) fail += compare_dictionaries(changing_dict, expected_dict, fails) # Now a test of the same function, # this time with a list of attribute dictionaries # as a value in `changing_dict` and `expected_dict`: attrib1_before = {'type': 'lo_element', 'element': 'Dabs'} attrib1_after = {'type': 'lo_element', 'element': 'SBMLDabs'} attrib2_before = {'type': 'inline_lo_element', 'element': 'ASTNode'} attrib2_after = {'type': 'inline_lo_element', 'element': 'ASTNode'} concrete_before = [{'element': 'test'}] concrete_after = [{'element': 'SBMLtest'}] attrib2_before['concrete'] = concrete_before attrib2_after['concrete'] = concrete_after attribs_before = [attrib1_before, attrib2_before] attribs_after = [attrib1_after, attrib2_after] changing_dict = {'name': 'Colin', 'baseClass': gv.baseClass, 'lo_class_name': 'Dabs', 'attribs': attribs_before} expected_dict = {'name': 'SBMLColin', 'baseClass': gv.baseClass, 'elementName': 'colin', 'lo_class_name': 'SBMLDabs', 'attribs': attribs_after} # Do not consume return value run_strfunc_test(sf.prefix_classes, changing_dict, None, fails) fail += compare_dictionaries(changing_dict, expected_dict, fails) # is_camel_case() tests data = {'FooParameter': True, 'fooParameter': True, 'fooparameter': False, 'Fooparameter': False} fail += execute_tests(sf.is_camel_case, data, fails) # Tests completed ############################################# test_functions.report('strfunc', fail, fails, not_tested) return fail