From 87ee86514eedad1b3df787f5a3705492d82acbee Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 4 May 2013 16:35:47 -0400 Subject: [PATCH] py3k specific syntax moved into an exec --- test/orm/test_instrumentation.py | 55 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/test/orm/test_instrumentation.py b/test/orm/test_instrumentation.py index 56ad4908bb..c3d24ebe7d 100644 --- a/test/orm/test_instrumentation.py +++ b/test/orm/test_instrumentation.py @@ -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!""" -- 2.47.3