From: Federico Caselli Date: Sat, 18 Apr 2020 16:10:59 +0000 (+0200) Subject: Enable pypy tests on github workflow X-Git-Tag: rel_1_4_0b1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c68f9fb87868c45fcadcc942ce4a35f10ff2f7ea;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Enable pypy tests on github workflow Fixes: #5223 Change-Id: I0952e54ed9af2952ea340be1945311376ffc1ad2 --- diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml index 89fc24b42a..61a878fdf1 100644 --- a/.github/workflows/run-test.yaml +++ b/.github/workflows/run-test.yaml @@ -33,6 +33,7 @@ jobs: - "3.6" - "3.7" - "3.8" + - "pypy3" build-type: - "cext" - "nocext" @@ -51,6 +52,9 @@ jobs: - os: "windows-latest" python-version: "2.7" pytest-args: "-k 'not MockReconnectTest and not test_hanging_connect_within_overflow'" + # autocommit tests fail on the ci for some reason + - python-version: "pypy3" + pytest-args: "-k 'not test_autocommit_on and not test_turn_autocommit_off_via_default_iso_level and not test_autocommit_isolation_level'" exclude: # c-extensions fail to build on windows for python 3.5 and 2.7 @@ -65,6 +69,12 @@ jobs: architecture: x86 - os: "macos-latest" architecture: x86 + # pypy does not have cext + - python-version: "pypy3" + build-type: "cext" + # pypy on windows has an ancient sqlite version (3.6) + - os: "windows-latest" + python-version: "pypy3" fail-fast: false diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 7b94bfa872..e73993e506 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1253,7 +1253,7 @@ class Mapper( if key == "__init__" and hasattr(method, "_sa_original_init"): method = method._sa_original_init if isinstance(method, types.MethodType): - method = method.im_func + method = method.__func__ if isinstance(method, types.FunctionType): if hasattr(method, "__sa_reconstructor__"): self._reconstructor = method diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index a4ace4e24d..dfefd3b95f 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -385,7 +385,7 @@ def %(name)s(%(args)s): code, {"target": target, "fn": fn}, fn.__name__ ) if not add_positional_parameters: - decorated.__defaults__ = getattr(fn, "im_func", fn).__defaults__ + decorated.__defaults__ = getattr(fn, "__func__", fn).__defaults__ decorated.__wrapped__ = fn return update_wrapper(decorated, fn) else: diff --git a/lib/sqlalchemy/util/__init__.py b/lib/sqlalchemy/util/__init__.py index 5fdcdf6542..7ce0ce12bb 100644 --- a/lib/sqlalchemy/util/__init__.py +++ b/lib/sqlalchemy/util/__init__.py @@ -73,6 +73,7 @@ from .compat import py2k # noqa from .compat import py36 # noqa from .compat import py37 # noqa from .compat import py3k # noqa +from .compat import pypy # noqa from .compat import quote_plus # noqa from .compat import raise_ # noqa from .compat import raise_from_cause # noqa diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index c71deffbc2..d4da216644 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -20,6 +20,7 @@ py37 = sys.version_info >= (3, 7) py36 = sys.version_info >= (3, 6) py3k = sys.version_info >= (3, 0) py2k = sys.version_info < (3, 0) +pypy = hasattr(sys, "pypy_version_info") cpython = platform.python_implementation() == "CPython" diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index bbdd3381fe..85a065e999 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -165,7 +165,7 @@ def %(name)s(%(args)s): env.update({targ_name: target, fn_name: fn}) decorated = _exec_code_in_env(code, env, fn.__name__) - decorated.__defaults__ = getattr(fn, "im_func", fn).__defaults__ + decorated.__defaults__ = getattr(fn, "__func__", fn).__defaults__ decorated.__wrapped__ = fn return update_wrapper(decorated, fn) @@ -784,7 +784,7 @@ def monkeypatch_proxied_specials( fn = getattr(from_cls, method) if not hasattr(fn, "__call__"): continue - fn = getattr(fn, "im_func", fn) + fn = getattr(fn, "__func__", fn) except AttributeError: continue try: diff --git a/test/base/test_utils.py b/test/base/test_utils.py index d5dece9a6c..d765a46131 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -389,7 +389,8 @@ class WrapCallableTest(fixtures.TestBase): lambda: my_functools_default(), my_functools_default ) eq_(c.__name__, "partial") - eq_(c.__doc__, my_functools_default.__call__.__doc__) + if not compat.pypy: # pypy fails this check + eq_(c.__doc__, my_functools_default.__call__.__doc__) eq_(c(), 5) diff --git a/test/engine/test_logging.py b/test/engine/test_logging.py index 0f0c08df4e..aa272c0cf5 100644 --- a/test/engine/test_logging.py +++ b/test/engine/test_logging.py @@ -8,6 +8,7 @@ from sqlalchemy import or_ from sqlalchemy import select from sqlalchemy import String from sqlalchemy import Table +from sqlalchemy import testing from sqlalchemy import util from sqlalchemy.sql import util as sql_util from sqlalchemy.testing import assert_raises @@ -479,10 +480,12 @@ class PoolLoggingTest(fixtures.TestBase): q = self._stpool_logging_fixture() self._test_queuepool(q, False) + @testing.requires.predictable_gc def test_queuepool_echo(self): q = self._queuepool_echo_fixture() self._test_queuepool(q) + @testing.requires.predictable_gc def test_queuepool_logging(self): q = self._queuepool_logging_fixture() self._test_queuepool(q) diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index fbe3942386..4cbdade18c 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -608,6 +608,7 @@ class PoolEventsTest(PoolTestBase): assert canary.call_args_list[0][0][0] is dbapi_con assert canary.call_args_list[0][0][2] is exc + @testing.requires.predictable_gc def test_checkin_event_gc(self): p, canary = self._checkin_event_fixture() diff --git a/test/orm/test_deferred.py b/test/orm/test_deferred.py index b2a04b8fff..6be967337a 100644 --- a/test/orm/test_deferred.py +++ b/test/orm/test_deferred.py @@ -1776,6 +1776,8 @@ class WithExpressionTest(fixtures.DeclarativeMappedTest): c1 = s.query(C).order_by(C.id) eq_(c1.all(), [C(c_expr=1), C(c_expr=1)]) + s.expunge_all() + c2 = ( s.query(C) .options(with_expression(C.c_expr, C.x * 2))