summaryrefslogtreecommitdiff
path: root/test/lib/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-12-05 12:51:24 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-12-05 12:51:24 -0500
commit1f9029597caf3d9d9e64e5a326508babfca60ebb (patch)
treed61b888173b7a0a6b6d4f061a3afad734812e1da /test/lib/util.py
parent49145a6940062486a6eec66bfe5c9d95c5f76c7a (diff)
downloadsqlalchemy-1f9029597caf3d9d9e64e5a326508babfca60ebb.tar.gz
- move topological, queue into util
- move function_named into test.lib.util - use @decorator for all decorators in test/
Diffstat (limited to 'test/lib/util.py')
-rw-r--r--test/lib/util.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/lib/util.py b/test/lib/util.py
index e5277f076..b8cc05a81 100644
--- a/test/lib/util.py
+++ b/test/lib/util.py
@@ -1,4 +1,4 @@
-from sqlalchemy.util import jython, function_named, defaultdict
+from sqlalchemy.util import jython, defaultdict, decorator
import gc
import time
@@ -105,3 +105,22 @@ def all_partial_orderings(tuples, elements):
return iter(_all_orderings(elements))
+
+def function_named(fn, name):
+ """Return a function with a given __name__.
+
+ Will assign to __name__ and return the original function if possible on
+ the Python implementation, otherwise a new function will be constructed.
+
+ This function should be phased out as much as possible
+ in favor of @decorator. Tests that "generate" many named tests
+ should be modernized.
+
+ """
+ try:
+ fn.__name__ = name
+ except TypeError:
+ fn = types.FunctionType(fn.func_code, fn.func_globals, name,
+ fn.func_defaults, fn.func_closure)
+ return fn
+