summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/profiling.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-01-03 12:10:57 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-01-04 00:25:07 -0500
commita54a0c6ec7aae89003cbb47c79a1850248f57a29 (patch)
tree19bcbea915d628ad22ba76f1e1b9d3d703f5c079 /lib/sqlalchemy/testing/profiling.py
parent5881fd274015af3de37f2ff0f91ff6a7c61c1540 (diff)
downloadsqlalchemy-a54a0c6ec7aae89003cbb47c79a1850248f57a29.tar.gz
Fix cext for Python 2; ensure C extensions build successfully
The C extensions have been broken since cc718cccc0bf8a01abdf4068c however CI did not find this, because the build degraded to non-C extensions without failing. Ensure that if cext is set, there is no fallback to non-cext build if the C extension build fails. Repair C related issues introduced in cc718cccc0bf8a01abdf4068c. As C extensions have been silently failing on 2.7 for some commits, the callcounts also needed to be adjusted for recent performance-related changes. That in turn required a fix to the profiling decorator to use signature rewriting in order to support py.test's fixture mechanism under Python 2, usage introduced under profiling in 89bf6d80a9. Fixes: #5076 Change-Id: Id968f10c85d6bf489298b1c318a1f869ad3e7d80
Diffstat (limited to 'lib/sqlalchemy/testing/profiling.py')
-rw-r--r--lib/sqlalchemy/testing/profiling.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/sqlalchemy/testing/profiling.py b/lib/sqlalchemy/testing/profiling.py
index fdf983a8f..14a6fc4ac 100644
--- a/lib/sqlalchemy/testing/profiling.py
+++ b/lib/sqlalchemy/testing/profiling.py
@@ -22,7 +22,6 @@ from . import config
from .util import gc_collect
from ..util import jython
from ..util import pypy
-from ..util import update_wrapper
from ..util import win32
@@ -232,17 +231,21 @@ def function_call_count(variance=0.05, times=1):
"""
- def decorate(fn):
- def wrap(*args, **kw):
- timerange = range(times)
- with count_functions(variance=variance):
- for time in timerange:
- rv = fn(*args, **kw)
- return rv
+ # use signature-rewriting decorator function so that py.test fixtures
+ # still work on py27. In Py3, update_wrapper() alone is good enough,
+ # likely due to the introduction of __signature__.
- return update_wrapper(wrap, fn)
+ from sqlalchemy.util import decorator
- return decorate
+ @decorator
+ def wrap(fn, *args, **kw):
+ timerange = range(times)
+ with count_functions(variance=variance):
+ for time in timerange:
+ rv = fn(*args, **kw)
+ return rv
+
+ return wrap
@contextlib.contextmanager