From 5b0919f3f5c7678c587858a47e38acd4a5b82f25 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 1 Feb 2014 18:21:04 -0500 Subject: - 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 Date: Sat Feb 1 15:09:04 2014 -0500 - first pass at new naming approach --- lib/sqlalchemy/testing/fixtures.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/sqlalchemy/testing') 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): -- cgit v1.2.1