diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-27 22:42:42 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-27 22:53:17 -0400 |
commit | 1cb94d89d5c4db7a914d9f30ebe0b676ab4e175b (patch) | |
tree | dceba064faa1ebc87c72c0e7c33121cf8597d80d | |
parent | 82f62509e8593a39c20d269d06fef3cf5e067556 (diff) | |
download | sqlalchemy-1cb94d89d5c4db7a914d9f30ebe0b676ab4e175b.tar.gz |
fix test ordering issues
-rw-r--r-- | lib/sqlalchemy/testing/plugin/plugin_base.py | 2 | ||||
-rw-r--r-- | test/ext/test_extendedattr.py | 4 | ||||
-rw-r--r-- | test/ext/test_mutable.py | 100 | ||||
-rw-r--r-- | test/ext/test_orderinglist.py | 4 |
4 files changed, 44 insertions, 66 deletions
diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index ed4f4d3b9..6902795e5 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -454,6 +454,8 @@ def start_test_class(cls): def stop_test_class(cls): + #from sqlalchemy import inspect + #assert not inspect(testing.db).get_table_names() engines.testing_reaper._stop_test_ctx() if not options.low_connections: assertions.global_cleanup_assertions() diff --git a/test/ext/test_extendedattr.py b/test/ext/test_extendedattr.py index 7a733696a..352b6b241 100644 --- a/test/ext/test_extendedattr.py +++ b/test/ext/test_extendedattr.py @@ -125,9 +125,11 @@ class MyClass(object): class UserDefinedExtensionTest(fixtures.ORMTest): @classmethod def teardown_class(cls): - clear_mappers() instrumentation._reinstall_default_lookups() + def teardown(self): + clear_mappers() + def test_instance_dict(self): class User(MyClass): pass diff --git a/test/ext/test_mutable.py b/test/ext/test_mutable.py index 32b3e11dd..dc0b5ba1c 100644 --- a/test/ext/test_mutable.py +++ b/test/ext/test_mutable.py @@ -6,17 +6,19 @@ from sqlalchemy.orm.instrumentation import ClassManager from sqlalchemy.testing.schema import Table, Column from sqlalchemy.testing import eq_, assert_raises_message from sqlalchemy.testing.util import picklers -from sqlalchemy import testing from sqlalchemy.testing import fixtures -import sys -import pickle +from sqlalchemy.ext.mutable import MutableComposite +from sqlalchemy.ext.mutable import MutableDict + class Foo(fixtures.BasicEntity): pass + class SubFoo(Foo): pass + class FooWithEq(object): def __init__(self, **kw): for k in kw: @@ -28,7 +30,38 @@ class FooWithEq(object): def __eq__(self, other): return self.id == other.id -from sqlalchemy.ext.mutable import MutableDict + +class Point(MutableComposite): + def __init__(self, x, y): + self.x = x + self.y = y + + def __setattr__(self, key, value): + object.__setattr__(self, key, value) + self.changed() + + def __composite_values__(self): + return self.x, self.y + + def __getstate__(self): + return self.x, self.y + + def __setstate__(self, state): + self.x, self.y = state + + def __eq__(self, other): + return isinstance(other, Point) and \ + other.x == self.x and \ + other.y == self.y + + +class MyPoint(Point): + @classmethod + def coerce(cls, key, value): + if isinstance(value, tuple): + value = Point(*value) + return value + class _MutableDictTestBase(object): run_define_tables = 'each' @@ -325,32 +358,7 @@ class _CompositeTestBase(object): @classmethod def _type_fixture(cls): - from sqlalchemy.ext.mutable import MutableComposite - global Point - - class Point(MutableComposite): - def __init__(self, x, y): - self.x = x - self.y = y - - def __setattr__(self, key, value): - object.__setattr__(self, key, value) - self.changed() - - def __composite_values__(self): - return self.x, self.y - - def __getstate__(self): - return self.x, self.y - - def __setstate__(self, state): - self.x, self.y = state - - def __eq__(self, other): - return isinstance(other, Point) and \ - other.x == self.x and \ - other.y == self.y return Point class MutableCompositesUnpickleTest(_CompositeTestBase, fixtures.MappedTest): @@ -473,39 +481,7 @@ class MutableCompositeCustomCoerceTest(_CompositeTestBase, fixtures.MappedTest): @classmethod def _type_fixture(cls): - from sqlalchemy.ext.mutable import MutableComposite - - global Point - - class Point(MutableComposite): - def __init__(self, x, y): - self.x = x - self.y = y - - @classmethod - def coerce(cls, key, value): - if isinstance(value, tuple): - value = Point(*value) - return value - - def __setattr__(self, key, value): - object.__setattr__(self, key, value) - self.changed() - - def __composite_values__(self): - return self.x, self.y - - def __getstate__(self): - return self.x, self.y - - def __setstate__(self, state): - self.x, self.y = state - - def __eq__(self, other): - return isinstance(other, Point) and \ - other.x == self.x and \ - other.y == self.y - return Point + return MyPoint @classmethod diff --git a/test/ext/test_orderinglist.py b/test/ext/test_orderinglist.py index 37b992f5b..3223c8048 100644 --- a/test/ext/test_orderinglist.py +++ b/test/ext/test_orderinglist.py @@ -45,8 +45,7 @@ class OrderingListTest(fixtures.TestBase): global metadata, slides_table, bullets_table, Slide, Bullet slides_table, bullets_table = None, None Slide, Bullet = None, None - if metadata: - metadata.clear() + metadata = MetaData(testing.db) def _setup(self, test_collection_class): """Build a relationship situation using the given @@ -54,7 +53,6 @@ class OrderingListTest(fixtures.TestBase): global metadata, slides_table, bullets_table, Slide, Bullet - metadata = MetaData(testing.db) slides_table = Table('test_Slides', metadata, Column('id', Integer, primary_key=True, test_needs_autoincrement=True), |