summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-01 18:21:04 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-01 18:21:04 -0500
commit5b0919f3f5c7678c587858a47e38acd4a5b82f25 (patch)
tree236ff9c4c4e8688aa9b1b5b5a9ea7f20ea3807fd /lib/sqlalchemy/testing
parent32a1db368599f6f3dbb3765ef5f11640d1725672 (diff)
downloadsqlalchemy-5b0919f3f5c7678c587858a47e38acd4a5b82f25.tar.gz
- Added a new feature which allows automated naming conventions to be
applied to :class:`.Constraint` and :class:`.Index` objects. Based on a recipe in the wiki, the new feature uses schema-events to set up names as various schema objects are associated with each other. The events then expose a configuration system through a new argument :paramref:`.MetaData.naming_convention`. This system allows production of both simple and custom naming schemes for constraints and indexes on a per-:class:`.MetaData` basis. [ticket:2923] commit 7e65e52c086652de3dd3303c723f98f09af54db8 Author: Mike Bayer <mike_mp@zzzcomputing.com> Date: Sat Feb 1 15:09:04 2014 -0500 - first pass at new naming approach
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/fixtures.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index 28541b14b..8717ce764 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -210,6 +210,24 @@ class TablesTest(TestBase):
[dict(zip(headers[table], column_values))
for column_values in rows[table]])
+from sqlalchemy import event
+class RemovesEvents(object):
+ @util.memoized_property
+ def _event_fns(self):
+ return set()
+
+ def event_listen(self, target, name, fn):
+ self._event_fns.add((target, name, fn))
+ event.listen(target, name, fn)
+
+ def teardown(self):
+ for key in self._event_fns:
+ event.remove(*key)
+ super_ = super(RemovesEvents, self)
+ if hasattr(super_, "teardown"):
+ super_.teardown()
+
+
class _ORMTest(object):