reorganized unit tests into subdirectories

This commit is contained in:
Mike Bayer 2006-06-05 17:25:51 +00:00
parent f8314ef9ff
commit 120dcee5a7
55 changed files with 200 additions and 63 deletions

View File

@ -21,6 +21,9 @@ more correctly documented
- restored global_connect() function, attaches to a DynamicMetaData
instance called "default_metadata". leaving MetaData arg to Table
out will use the default metadata.
- fixes to session cascade behavior, entity_name propigation
- reorganized unittests into subdirectories
0.2.1
- "pool" argument to create_engine() properly propigates
- fixes to URL, raises exception if not parsed, does not pass blank

42
README.unittests Normal file
View File

@ -0,0 +1,42 @@
To run unit tests (assuming unix-style commandline, adjust as needed for windows):
cd into the SQLAlchemy distribution directory.
Set up the PYTHONPATH:
export PYTHONPATH=./lib/:./test/
To run all tests:
python test/alltests.py
Help is available via:
python test/alltests.py --help
usage: alltests.py [options] files...
options:
-h, --help show this help message and exit
--dburi=DBURI database uri (overrides --db)
--db=DB prefab database uri (sqlite, sqlite_file, postgres,
mysql, oracle, oracle8, mssql)
--mockpool use mock pool
--verbose full debug echoing
--noecho Disable SQL statement echoing
--quiet be totally quiet
--nothreadlocal dont use thread-local mod
--enginestrategy=ENGINESTRATEGY
engine strategy (plain or threadlocal, defaults to SA
default)
Any unittest module can be run directly from the module file (same commandline options):
python test/orm/mapper.py
Additionally, to run a speciic test within the module, specify it as ClassName.methodname:
python test/orm/mapper.py MapperTest.testget

View File

@ -1,71 +1,16 @@
import testbase
import unittest
import orm.alltests as orm
import base.alltests as base
import sql.alltests as sql
import engine.alltests as engine
import ext.alltests as ext
def suite():
modules_to_test = (
# core utilities
'historyarray',
'attributes',
'dependency',
# connectivity, execution
'pool',
'transaction',
# schema/tables
'reflection',
'testtypes',
'indexes',
# SQL syntax
'select',
'selectable',
'case_statement',
# assorted round-trip tests
'query',
# defaults, sequences (postgres/oracle)
'defaults',
# ORM selecting
'mapper',
'selectresults',
'lazytest1',
'eagertest1',
'eagertest2',
# ORM persistence
'sessioncontext',
'objectstore',
'cascade',
'relationships',
'association',
# cyclical ORM persistence
'cycles',
'poly_linked_list',
# more select/persistence, backrefs
'entity',
'manytomany',
'onetoone',
'inheritance',
'inheritance2',
'inheritance3',
'polymorph',
# extensions
'proxy_engine',
'activemapper',
'sqlsoup'
#'wsgi_test',
)
alltests = unittest.TestSuite()
for module in map(__import__, modules_to_test):
alltests.addTest(unittest.findTestCases(module, suiteClass=None))
for suite in (base, engine, sql, orm, ext):
alltests.addTest(suite.suite())
return alltests

0
test/base/__init__.py Normal file
View File

21
test/base/alltests.py Normal file
View File

@ -0,0 +1,21 @@
import testbase
import unittest
def suite():
modules_to_test = (
# core utilities
'base.historyarray',
'base.attributes',
'base.dependency',
)
alltests = unittest.TestSuite()
for name in modules_to_test:
mod = __import__(name)
for token in name.split('.')[1:]:
mod = getattr(mod, token)
alltests.addTest(unittest.findTestCases(mod, suiteClass=None))
return alltests
if __name__ == '__main__':
testbase.runTests(suite())

0
test/engine/__init__.py Normal file
View File

28
test/engine/alltests.py Normal file
View File

@ -0,0 +1,28 @@
import testbase
import unittest
def suite():
modules_to_test = (
# connectivity, execution
'engine.parseconnect',
'engine.pool',
'engine.transaction',
# schema/tables
'engine.reflection',
'engine.proxy_engine'
)
alltests = unittest.TestSuite()
for name in modules_to_test:
mod = __import__(name)
for token in name.split('.')[1:]:
mod = getattr(mod, token)
alltests.addTest(unittest.findTestCases(mod, suiteClass=None))
return alltests
if __name__ == '__main__':
testbase.runTests(suite())

0
test/ext/__init__.py Normal file
View File

19
test/ext/alltests.py Normal file
View File

@ -0,0 +1,19 @@
import testbase
import unittest
def suite():
modules_to_test = (
'ext.activemapper',
'ext.sqlsoup'
)
alltests = unittest.TestSuite()
for name in modules_to_test:
mod = __import__(name)
for token in name.split('.')[1:]:
mod = getattr(mod, token)
alltests.addTest(unittest.findTestCases(mod, suiteClass=None))
return alltests
if __name__ == '__main__':
testbase.runTests(suite())

0
test/orm/__init__.py Normal file
View File

39
test/orm/alltests.py Normal file
View File

@ -0,0 +1,39 @@
import testbase
import unittest
def suite():
modules_to_test = (
'orm.mapper',
'orm.selectresults',
'orm.lazytest1',
'orm.eagertest1',
'orm.eagertest2',
'orm.sessioncontext',
'orm.objectstore',
'orm.cascade',
'orm.relationships',
'orm.association',
'orm.cycles',
'orm.poly_linked_list',
'orm.entity',
'orm.manytomany',
'orm.onetoone',
'orm.inheritance',
'orm.inheritance2',
'orm.inheritance3',
'orm.polymorph'
)
alltests = unittest.TestSuite()
for name in modules_to_test:
mod = __import__(name)
for token in name.split('.')[1:]:
mod = getattr(mod, token)
alltests.addTest(unittest.findTestCases(mod, suiteClass=None))
return alltests
if __name__ == '__main__':
testbase.runTests(suite())

0
test/sql/__init__.py Normal file
View File

32
test/sql/alltests.py Normal file
View File

@ -0,0 +1,32 @@
import testbase
import unittest
def suite():
modules_to_test = (
'sql.testtypes',
'sql.indexes',
# SQL syntax
'sql.select',
'sql.selectable',
'sql.case_statement',
# assorted round-trip tests
'sql.query',
# defaults, sequences (postgres/oracle)
'sql.defaults',
)
alltests = unittest.TestSuite()
for name in modules_to_test:
mod = __import__(name)
for token in name.split('.')[1:]:
mod = getattr(mod, token)
alltests.addTest(unittest.findTestCases(mod, suiteClass=None))
return alltests
if __name__ == '__main__':
testbase.runTests(suite())

View File

@ -4,6 +4,14 @@ from testbase import PersistTest, AssertMixin
import testbase
import sqlalchemy.engine.url as url
import sqlalchemy.types
# TODO: cant get cPickle to pickle the "Foo" class from this module,
# now that its moved
import pickle
sqlalchemy.types.pickle = pickle
db = testbase.db
class MyType(types.TypeEngine):