commit 1607c5c19f8ef362be7182b0ee0fddc6a3d3140e Author: Federico Caselli Date: Sat Apr 18 18:10:59 2020 +0200 Enable pypy tests on github workflow Fixes: #5223 Change-Id: I0952e54ed9af2952ea340be1945311376ffc1ad2 diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 6f3170a9e..0427eeac5 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1326,7 +1326,7 @@ class Mapper(InspectionAttr): 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 ad4ebb656..dc47f671e 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -340,7 +340,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/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 7de16bcdf..e256d7764 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -151,7 +151,7 @@ def %(name)s(%(args)s): decorated = _exec_code_in_env( code, {targ_name: target, fn_name: fn}, 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) @@ -751,7 +751,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 8356de61b..c04dea7cd 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -411,7 +411,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 fe4ff44a7..e14c3a37d 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_message @@ -460,10 +461,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 3b989959e..c8cd89555 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 f8817bbd7..2bf466c15 100644 --- a/test/orm/test_deferred.py +++ b/test/orm/test_deferred.py @@ -1700,6 +1700,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)) commit 8d3ac81a8794bdd3532ad07427edf9f48493919d Date: Wed Oct 14 18:25:45 2020 +0200 Skip a failing test that got removed in master https://github.com/sqlalchemy/sqlalchemy/commit/a9b068ae564e5e775e312373088545b75aeaa1b0 diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index 156898f..0d6dc72 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -560,7 +560,7 @@ class StrongIdentityMapTest(_fixtures.FixtureTest): def test_prune_imap(self): self._test_prune(self._strong_ident_fixture) - def test_prune_events(self): + def _test_prune_events(self): self._test_prune(self._event_fixture) @testing.fails_if(lambda: pypy, "pypy has a real GC") commit 1a1cc0e623698a75274f1525d2d14464ff738b86 Date: Wed Oct 14 18:28:56 2020 +0200 Fix PyPy-related tests Partial backport of https://github.com/sqlalchemy/sqlalchemy/commit/9e31fc74089cf565df5f275d22eb8ae5414d6e45 diff --git a/test/base/test_utils.py b/test/base/test_utils.py diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 8356de61b..c3d25b824 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -1725,7 +1725,7 @@ class ArgInspectionTest(fixtures.TestBase): assert_raises(TypeError, get_callable_argspec, datetime.datetime.now) - @fails_if(lambda: util.pypy, "pypy returns plain *arg, **kw") + @testing.requires.cpython def test_callable_argspec_obj_init(self): assert_raises(TypeError, get_callable_argspec, object) @@ -2154,10 +2154,7 @@ class TestFormatArgspec(_Py3KFixtures, fixtures.TestBase): grouped=False, ) - @testing.fails_if( - lambda: util.pypy, - "pypy doesn't report Obj.__init__ as object.__init__", - ) + @testing.requires.cpython def test_init_grouped(self): object_spec = { "args": "(self)", @@ -2181,10 +2178,7 @@ class TestFormatArgspec(_Py3KFixtures, fixtures.TestBase): self._test_init(None, object_spec, wrapper_spec, custom_spec) self._test_init(True, object_spec, wrapper_spec, custom_spec) - @testing.fails_if( - lambda: util.pypy, - "pypy doesn't report Obj.__init__ as object.__init__", - ) + @testing.requires.cpython def test_init_bare(self): object_spec = { "args": "self",