]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Enable pypy tests on github workflow
authorFederico Caselli <cfederico87@gmail.com>
Sat, 18 Apr 2020 16:10:59 +0000 (18:10 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Fri, 2 Oct 2020 19:21:11 +0000 (21:21 +0200)
Fixes: #5223
Change-Id: I0952e54ed9af2952ea340be1945311376ffc1ad2

.github/workflows/run-test.yaml
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/testing/plugin/pytestplugin.py
lib/sqlalchemy/util/__init__.py
lib/sqlalchemy/util/compat.py
lib/sqlalchemy/util/langhelpers.py
test/base/test_utils.py
test/engine/test_logging.py
test/engine/test_pool.py
test/orm/test_deferred.py

index 89fc24b42a0b9367158dea0a1a72ab75621550ca..61a878fdf1f027ede3d8d88ed8a8227a80bf732d 100644 (file)
@@ -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
 
index 7b94bfa872b06c904a6e1cc57109cb0977c392f5..e73993e5061aa44c03fffe68ac0820d5b86015bd 100644 (file)
@@ -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
index a4ace4e24d20ca768b0e2f8df33bdc7633c06706..dfefd3b95f9d580fe6cb3f9720c41b9c8ab0059b 100644 (file)
@@ -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:
index 5fdcdf65423a0845b1e28a7cd8cdc0cb5458fe7c..7ce0ce12bb5a74239cfb8597e610efa0a8e41446 100644 (file)
@@ -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
index c71deffbc2a6d1b8b6cf77e6903f0f98d6eb7deb..d4da2166441e751d9e7a5ca72eded2774fd61872 100644 (file)
@@ -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"
index bbdd3381fe3d2b9709661601c8854209df685e89..85a065e999fe0bc5dca8818443b2cc67b38864b8 100644 (file)
@@ -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:
index d5dece9a6c9e6a516e6aee5f9519809395ca2321..d765a46131ad239aa85bea8d5b249f235d36c1e4 100644 (file)
@@ -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)
 
 
index 0f0c08df4e8290709a9f3aebea4d04032b93b342..aa272c0cf545085da898b43e8627a238c1b6d824 100644 (file)
@@ -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)
index fbe39423868460edded4bc50238e8223d3b8c55d..4cbdade18c7fbec63452fa4cd4d633ab98beaf77 100644 (file)
@@ -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()
 
index b2a04b8fff6cb6f5f4945162d971871109cae213..6be967337a9031e333e6a9f4d6c7c59c29d5c65d 100644 (file)
@@ -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))