summaryrefslogtreecommitdiff
path: root/test/lib/util.py
diff options
context:
space:
mode:
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
+