From: Mike Bayer Date: Mon, 5 Jun 2006 17:25:51 +0000 (+0000) Subject: reorganized unit tests into subdirectories X-Git-Tag: rel_0_2_2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=120dcee5a71187d4bebfe50aedbbefb09184cac1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git reorganized unit tests into subdirectories --- diff --git a/CHANGES b/CHANGES index 6b196f4402..d22e19fc3a 100644 --- a/CHANGES +++ b/CHANGES @@ -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 diff --git a/README.unittests b/README.unittests new file mode 100644 index 0000000000..74c7ccac13 --- /dev/null +++ b/README.unittests @@ -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 + + diff --git a/test/alltests.py b/test/alltests.py index 183fc14924..147d26d2cf 100644 --- a/test/alltests.py +++ b/test/alltests.py @@ -1,71 +1,16 @@ import testbase import unittest -def suite(): - modules_to_test = ( - # core utilities - 'historyarray', - 'attributes', - 'dependency', - - # connectivity, execution - 'pool', - 'transaction', - - # schema/tables - 'reflection', - 'testtypes', - 'indexes', +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 - # 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', - - ) +def suite(): 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 diff --git a/test/base/__init__.py b/test/base/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/base/alltests.py b/test/base/alltests.py new file mode 100644 index 0000000000..2ef5b87948 --- /dev/null +++ b/test/base/alltests.py @@ -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()) diff --git a/test/attributes.py b/test/base/attributes.py similarity index 100% rename from test/attributes.py rename to test/base/attributes.py diff --git a/test/dependency.py b/test/base/dependency.py similarity index 100% rename from test/dependency.py rename to test/base/dependency.py diff --git a/test/historyarray.py b/test/base/historyarray.py similarity index 100% rename from test/historyarray.py rename to test/base/historyarray.py diff --git a/test/engine/__init__.py b/test/engine/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/engine/alltests.py b/test/engine/alltests.py new file mode 100644 index 0000000000..c63cb2861c --- /dev/null +++ b/test/engine/alltests.py @@ -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()) diff --git a/test/autoconnect_engine.py b/test/engine/autoconnect_engine.py similarity index 100% rename from test/autoconnect_engine.py rename to test/engine/autoconnect_engine.py diff --git a/test/parseconnect.py b/test/engine/parseconnect.py similarity index 100% rename from test/parseconnect.py rename to test/engine/parseconnect.py diff --git a/test/pool.py b/test/engine/pool.py similarity index 100% rename from test/pool.py rename to test/engine/pool.py diff --git a/test/proxy_engine.py b/test/engine/proxy_engine.py similarity index 100% rename from test/proxy_engine.py rename to test/engine/proxy_engine.py diff --git a/test/reflection.py b/test/engine/reflection.py similarity index 100% rename from test/reflection.py rename to test/engine/reflection.py diff --git a/test/transaction.py b/test/engine/transaction.py similarity index 100% rename from test/transaction.py rename to test/engine/transaction.py diff --git a/test/ext/__init__.py b/test/ext/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/activemapper.py b/test/ext/activemapper.py similarity index 100% rename from test/activemapper.py rename to test/ext/activemapper.py diff --git a/test/ext/alltests.py b/test/ext/alltests.py new file mode 100644 index 0000000000..67513f0328 --- /dev/null +++ b/test/ext/alltests.py @@ -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()) diff --git a/test/legacy_objectstore.py b/test/ext/legacy_objectstore.py similarity index 100% rename from test/legacy_objectstore.py rename to test/ext/legacy_objectstore.py diff --git a/test/sqlsoup.py b/test/ext/sqlsoup.py similarity index 100% rename from test/sqlsoup.py rename to test/ext/sqlsoup.py diff --git a/test/wsgi_test.py b/test/ext/wsgi_test.py similarity index 100% rename from test/wsgi_test.py rename to test/ext/wsgi_test.py diff --git a/test/orm/__init__.py b/test/orm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/orm/alltests.py b/test/orm/alltests.py new file mode 100644 index 0000000000..4c038f1221 --- /dev/null +++ b/test/orm/alltests.py @@ -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()) diff --git a/test/association.py b/test/orm/association.py similarity index 100% rename from test/association.py rename to test/orm/association.py diff --git a/test/cascade.py b/test/orm/cascade.py similarity index 100% rename from test/cascade.py rename to test/orm/cascade.py diff --git a/test/cycles.py b/test/orm/cycles.py similarity index 100% rename from test/cycles.py rename to test/orm/cycles.py diff --git a/test/eagertest1.py b/test/orm/eagertest1.py similarity index 100% rename from test/eagertest1.py rename to test/orm/eagertest1.py diff --git a/test/eagertest2.py b/test/orm/eagertest2.py similarity index 100% rename from test/eagertest2.py rename to test/orm/eagertest2.py diff --git a/test/entity.py b/test/orm/entity.py similarity index 100% rename from test/entity.py rename to test/orm/entity.py diff --git a/test/inheritance.py b/test/orm/inheritance.py similarity index 100% rename from test/inheritance.py rename to test/orm/inheritance.py diff --git a/test/inheritance2.py b/test/orm/inheritance2.py similarity index 100% rename from test/inheritance2.py rename to test/orm/inheritance2.py diff --git a/test/inheritance3.py b/test/orm/inheritance3.py similarity index 100% rename from test/inheritance3.py rename to test/orm/inheritance3.py diff --git a/test/lazytest1.py b/test/orm/lazytest1.py similarity index 100% rename from test/lazytest1.py rename to test/orm/lazytest1.py diff --git a/test/manytomany.py b/test/orm/manytomany.py similarity index 100% rename from test/manytomany.py rename to test/orm/manytomany.py diff --git a/test/mapper.py b/test/orm/mapper.py similarity index 100% rename from test/mapper.py rename to test/orm/mapper.py diff --git a/test/objectstore.py b/test/orm/objectstore.py similarity index 100% rename from test/objectstore.py rename to test/orm/objectstore.py diff --git a/test/onetoone.py b/test/orm/onetoone.py similarity index 100% rename from test/onetoone.py rename to test/orm/onetoone.py diff --git a/test/poly_linked_list.py b/test/orm/poly_linked_list.py similarity index 100% rename from test/poly_linked_list.py rename to test/orm/poly_linked_list.py diff --git a/test/polymorph.py b/test/orm/polymorph.py similarity index 100% rename from test/polymorph.py rename to test/orm/polymorph.py diff --git a/test/relationships.py b/test/orm/relationships.py similarity index 100% rename from test/relationships.py rename to test/orm/relationships.py diff --git a/test/selectresults.py b/test/orm/selectresults.py similarity index 100% rename from test/selectresults.py rename to test/orm/selectresults.py diff --git a/test/sessioncontext.py b/test/orm/sessioncontext.py similarity index 100% rename from test/sessioncontext.py rename to test/orm/sessioncontext.py diff --git a/test/masscreate.py b/test/perf/masscreate.py similarity index 100% rename from test/masscreate.py rename to test/perf/masscreate.py diff --git a/test/masscreate2.py b/test/perf/masscreate2.py similarity index 100% rename from test/masscreate2.py rename to test/perf/masscreate2.py diff --git a/test/massload.py b/test/perf/massload.py similarity index 100% rename from test/massload.py rename to test/perf/massload.py diff --git a/test/sql/__init__.py b/test/sql/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/sql/alltests.py b/test/sql/alltests.py new file mode 100644 index 0000000000..23a7a62365 --- /dev/null +++ b/test/sql/alltests.py @@ -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()) diff --git a/test/case_statement.py b/test/sql/case_statement.py similarity index 100% rename from test/case_statement.py rename to test/sql/case_statement.py diff --git a/test/defaults.py b/test/sql/defaults.py similarity index 100% rename from test/defaults.py rename to test/sql/defaults.py diff --git a/test/indexes.py b/test/sql/indexes.py similarity index 100% rename from test/indexes.py rename to test/sql/indexes.py diff --git a/test/query.py b/test/sql/query.py similarity index 100% rename from test/query.py rename to test/sql/query.py diff --git a/test/select.py b/test/sql/select.py similarity index 100% rename from test/select.py rename to test/sql/select.py diff --git a/test/selectable.py b/test/sql/selectable.py similarity index 100% rename from test/selectable.py rename to test/sql/selectable.py diff --git a/test/testtypes.py b/test/sql/testtypes.py similarity index 98% rename from test/testtypes.py rename to test/sql/testtypes.py index db1fbca206..f369bd3840 100644 --- a/test/testtypes.py +++ b/test/sql/testtypes.py @@ -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):