]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
py3k specific syntax moved into an exec
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 4 May 2013 20:35:47 +0000 (16:35 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 4 May 2013 20:35:47 +0000 (16:35 -0400)
test/orm/test_instrumentation.py

index 56ad4908bb6336ce29d0b7e38e05a514224974a1..c3d24ebe7de671074ff94ba7d371764275afeadf 100644 (file)
@@ -540,31 +540,6 @@ class NativeInstrumentationTest(fixtures.ORMTest):
 class Py3KFunctionInstTest(fixtures.ORMTest):
     __requires__ = ("python3", )
 
-# start Py3K
-    def _kw_only_fixture(self):
-        class A(object):
-            def __init__(self, a, *, b, c):
-                self.a = a
-                self.b = b
-                self.c = c
-        return self._instrument(A)
-
-    def _kw_plus_posn_fixture(self):
-        class A(object):
-            def __init__(self, a, *args, b, c):
-                self.a = a
-                self.b = b
-                self.c = c
-        return self._instrument(A)
-
-    def _kw_opt_fixture(self):
-        class A(object):
-            def __init__(self, a, *, b, c="c"):
-                self.a = a
-                self.b = b
-                self.c = c
-        return self._instrument(A)
-# end Py3K
 
     def _instrument(self, cls):
         manager = instrumentation.register_class(cls)
@@ -615,6 +590,36 @@ class Py3KFunctionInstTest(fixtures.ORMTest):
             cls, "a", "b", c="c"
         )
 
+if util.py3k:
+    _locals = {}
+    exec("""
+def _kw_only_fixture(self):
+    class A(object):
+        def __init__(self, a, *, b, c):
+            self.a = a
+            self.b = b
+            self.c = c
+    return self._instrument(A)
+
+def _kw_plus_posn_fixture(self):
+    class A(object):
+        def __init__(self, a, *args, b, c):
+            self.a = a
+            self.b = b
+            self.c = c
+    return self._instrument(A)
+
+def _kw_opt_fixture(self):
+    class A(object):
+        def __init__(self, a, *, b, c="c"):
+            self.a = a
+            self.b = b
+            self.c = c
+    return self._instrument(A)
+""", _locals)
+    for k in _locals:
+        setattr(Py3KFunctionInstTest, k, _locals[k])
+
 class MiscTest(fixtures.ORMTest):
     """Seems basic, but not directly covered elsewhere!"""