Thread: [Modeling-cvs] ProjectModeling/Modeling/tests run.py,1.8,1.9 test_EditingContext_Global.py,1.48,1.49
Status: Abandoned
Brought to you by:
sbigaret
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19962/Modeling/tests Modified Files: run.py test_EditingContext_Global.py test_EditingContext_Global_Inheritance.py test_EditingContext_ParentChild.py utils.py Log Message: Integrated patch #814055: Dynamic creation of packages/modules/classes Index: run.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/run.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** run.py 14 Feb 2004 18:17:21 -0000 1.8 --- run.py 16 Feb 2004 20:01:08 -0000 1.9 *************** *** 33,37 **** if __name__ == "__main__": utils.disable_model_cache() # test_EntityClassDescription requires it ! # Modeling Layer import test_Model --- 33,44 ---- if __name__ == "__main__": utils.disable_model_cache() # test_EntityClassDescription requires it ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) ! ! # Modeling Layer import test_Model Index: test_EditingContext_Global.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** test_EditingContext_Global.py 14 Feb 2004 19:19:48 -0000 1.48 --- test_EditingContext_Global.py 16 Feb 2004 20:01:08 -0000 1.49 *************** *** 39,47 **** import unittest, sys import utils if __name__ == "__main__": utils.disable_model_cache() ! utils.fixpath() from Modeling import ModelSet, Model from Modeling.EditingContext import EditingContext from Modeling.FetchSpecification import FetchSpecification --- 39,57 ---- import unittest, sys import utils + if __name__ == "__main__": utils.disable_model_cache() ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) from Modeling import ModelSet, Model + + from AuthorBooks.Writer import Writer + from AuthorBooks.Book import Book + from Modeling.EditingContext import EditingContext from Modeling.FetchSpecification import FetchSpecification *************** *** 52,57 **** from Modeling import Database - from testPackages.AuthorBooks.Writer import Writer - from testPackages.AuthorBooks.Book import Book class Writer_test07(Writer): --- 62,65 ---- Index: test_EditingContext_Global_Inheritance.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global_Inheritance.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_EditingContext_Global_Inheritance.py 14 Feb 2004 19:00:28 -0000 1.23 --- test_EditingContext_Global_Inheritance.py 16 Feb 2004 20:01:08 -0000 1.24 *************** *** 40,44 **** if __name__ == "__main__": utils.disable_model_cache() ! utils.fixpath() from Modeling import ModelSet, Model --- 40,49 ---- if __name__ == "__main__": utils.disable_model_cache() ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) from Modeling import ModelSet, Model *************** *** 926,930 **** suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestEditingContext_Global_Inheritance, ! "test")) return suite --- 931,935 ---- suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestEditingContext_Global_Inheritance, ! "test_")) return suite Index: test_EditingContext_ParentChild.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_ParentChild.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_EditingContext_ParentChild.py 14 Feb 2004 18:17:21 -0000 1.15 --- test_EditingContext_ParentChild.py 16 Feb 2004 20:01:08 -0000 1.16 *************** *** 40,44 **** if __name__ == "__main__": utils.disable_model_cache() ! utils.fixpath() from Modeling import ModelSet, Model --- 40,49 ---- if __name__ == "__main__": utils.disable_model_cache() ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) from Modeling import ModelSet, Model *************** *** 51,56 **** from Modeling import Database ! from testPackages.AuthorBooks.Writer import Writer ! from testPackages.AuthorBooks.Book import Book from StoreEmployees import Employee --- 56,61 ---- from Modeling import Database ! from AuthorBooks.Writer import Writer ! from AuthorBooks.Book import Book from StoreEmployees import Employee Index: utils.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/utils.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** utils.py 14 Feb 2004 18:17:21 -0000 1.9 --- utils.py 16 Feb 2004 20:01:08 -0000 1.10 *************** *** 34,42 **** __version__='$Revision$'[11:-2] ! import os, sys # ! # mydir is where this file is, codedir is 2 level up ! def fixpath(): mydir = os.path.abspath(os.path.dirname(__file__)) codedir = os.path.dirname(os.path.dirname(mydir)) --- 34,50 ---- __version__='$Revision$'[11:-2] ! import os, sys, unittest # ! def fixpath(include_testPackages=1): ! """ ! Prepends directory ../.. to sys.path, so that any import from Modeling ! imports the modules in this directory, rather then the possibly installed ! one: we want to test the framework in this directory. ! ! If include_testPackages is true, we also prepends the testPackages/ ! directory to sys.path ! """ ! # mydir is where this file is, codedir is 2 level up mydir = os.path.abspath(os.path.dirname(__file__)) codedir = os.path.dirname(os.path.dirname(mydir)) *************** *** 44,53 **** sys.path=[codedir]+sys.path # add the testPackages directory to the python path ! testPackageDir=os.path.join(mydir, 'testPackages') ! if testPackageDir not in sys.path: ! sys.path=[testPackageDir]+sys.path ! fixpath() ! import unittest def run_suite(suite, outf=sys.stdout, errf=None, verbosity=0): --- 52,110 ---- sys.path=[codedir]+sys.path # add the testPackages directory to the python path ! if include_testPackages: ! testPackageDir=os.path.join(mydir, 'testPackages') ! if testPackageDir not in sys.path: ! sys.path=[testPackageDir]+sys.path ! def dynamically_build_test_packages(argv): ! """ ! Uses Modeling.dynamic to dynamically create the test packages, depending on ! the values stored in the list 'argv': ! ! - if argv contains neither '-c', '-m' nor '-M', simply return ! ! - otherwise, load the models AuthorBooks and StoreEmployees, then: ! ! - if '-c' is in argv, dynamic.build(define_properties=0) the package ! ! - if '-C' is in argv, dynamic.build(define_properties=1) the package ! ! - if '-m' is in argv, dynamic.build_with_metaclass(define_properties=0) ! the package ! ! - if '-M' is in argv, dynamic.build_with_metaclass(define_properties=1) ! the package ! ! when this method returns, either '-c', '-C', '-m' or '-M' is removed from ! the list 'argv'. ! ! See the tests usage(), dynamic.build(), dynamic.build_with_metaclass() ! """ ! if '-c' not in argv and '-C' not in argv \ ! and '-m' not in argv and '-M' not in argv: ! return ! from Modeling import ModelSet, Model ! from Modeling.dynamic import build, build_with_metaclass ! verbose='-v' in argv or '-V' in argv ! model1=Model.searchModel('AuthorBooks', 'xmlmodels', verbose=verbose) ! model2=Model.searchModel('StoreEmployees', 'xmlmodels', verbose=verbose) ! ModelSet.defaultModelSet().addModel(model1) ! ModelSet.defaultModelSet().addModel(model2) ! if '-c' in argv: ! build(model1, define_properties=0) ! build(model2, define_properties=0) ! argv.remove('-c') ! if '-C' in argv: ! build(model1, define_properties=1) ! build(model2, define_properties=1) ! argv.remove('-C') ! elif '-m' in argv: ! build_with_metaclass(model1, define_properties=0, verbose=verbose) ! build_with_metaclass(model2, define_properties=0, verbose=verbose) ! argv.remove('-m') ! elif '-M' in argv: ! build_with_metaclass(model1, define_properties=1, verbose=verbose) ! build_with_metaclass(model2, define_properties=1, verbose=verbose) ! argv.remove('-M') def run_suite(suite, outf=sys.stdout, errf=None, verbosity=0): *************** *** 73,77 **** try: del os.environ['MDL_ENABLE_SIMPLE_METHOD_CACHE'] ! except: pass --- 130,134 ---- try: del os.environ['MDL_ENABLE_SIMPLE_METHOD_CACHE'] ! except KeyError: pass |