#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
#-----------------------------------------------------------------------------
# Modeling Framework: an Object-Relational Bridge for python
#
# Copyright (c) 2001-2004 Sbastien Bigaret <sbigaret@users.sourceforge.net>
# All rights reserved.
#
# This file is part of the Modeling Framework.
#
# This code is distributed under a "3-clause BSD"-style license;
# see the LICENSE file for details.
#-----------------------------------------------------------------------------
"""Run all tests."""
__version__='$Revision: 950 $'[11:-2]
import sys, getopt
import utils
import unittest
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)
#
import test_delegation
# Modeling Layer
import test_Model
import test_Attribute
import test_Entity
import test_Relationship
import test_ImportExport
import test_PyModel
# Control Layer
import test_GlobalID # before EditingContext
import test_KeyValueCoding
import test_RelationshipManipulation # Needs KeyValueC.
import test_Validation
import test_Qualifier
import test_FetchSpecification
import test_SortOrderings
import test_ObserverCenter
import test_EntityClassDescription
import test_EditingContext # srement deplacer vers le bas (ou alors split)
import test_DatabaseContext
# Ordre de mise en place?
# Access Layer
import test_FaultHandler
import test_Adaptor
import test_SQLExpression
import test_SchemaGeneration
import test_dynamic
def usage(prgName, exitStatus=None):
_usage="""%s [-v] [-V]
Runs the tests for the Modeling package
Options
--------
-v Minimally verbose
-V Really verbose
-g run the so-called 'global' tests as well -- they are called 'global'
because they need the whole framework (including the
PostgresqlAdaptorLayer and a postgresql DB) to be functional.
-p profile
-h Prints this message
""" % prgName
if exitStatus is not None:
print _usage
sys.exit(exitStatus)
else:
return _usage
def test_suite():
suite=unittest.TestSuite()
if global_tests: # should be the first one, or this is pretty useless
import test_CooperatingObjectStoreNeededNotification
suite.addTest(test_CooperatingObjectStoreNeededNotification.test_suite())
suite.addTest(test_delegation.test_suite())
suite.addTest(test_Model.test_suite())
suite.addTest(test_Entity.test_suite())
suite.addTest(test_Attribute.test_suite())
suite.addTest(test_Relationship.test_suite())
suite.addTest(test_ImportExport.test_suite())
suite.addTest(test_PyModel.test_suite())
suite.addTest(test_GlobalID.test_suite())
suite.addTest(test_KeyValueCoding.test_suite())
suite.addTest(test_RelationshipManipulation.test_suite()) # Needs KeyValueC.
suite.addTest(test_Validation.test_suite())
suite.addTest(test_Qualifier.test_suite())
suite.addTest(test_SortOrderings.test_suite())
suite.addTest(test_ObserverCenter.test_suite())
suite.addTest(test_EntityClassDescription.test_suite())
suite.addTest(test_EditingContext.test_suite())
suite.addTest(test_DatabaseContext.test_suite())
suite.addTest(test_FaultHandler.test_suite())
suite.addTest(test_Adaptor.test_suite())
suite.addTest(test_SQLExpression.test_suite())
suite.addTest(test_SchemaGeneration.test_suite())
suite.addTest(test_dynamic.test_suite())
# global
if global_tests:
import test_EditingContext_Global
suite.addTest(test_EditingContext_Global.test_suite())
return suite
verbose=0 # we need this to be global, for use by profile.run()
global_tests=0
def main(args):
me=args[0]
try: options, args = getopt.getopt(sys.argv[1:], 'hvVpg')
except: usage(me, 1)
global verbose
global global_tests
profile=0
for k, v in options:
if k=='-h': usage(me, 1)
if k=='-v': verbose=1; continue
if k=='-V': verbose="Y"; continue
if k=='-p': profile=1; continue
if k=='-g': global_tests=1; continue
if args: usage(me, 1) #raise 'Unexpected arguments', args
if profile:
import profile
profile.run('utils.run_suite(test_suite(), verbosity=verbose)',
'profile.out')
return
else:
return utils.run_suite(test_suite(), verbosity=verbose)
if __name__ == "__main__":
errs = main(sys.argv)
sys.exit(errs and 1 or 0)
|