summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-04-18 18:10:59 +0200
committerFederico Caselli <cfederico87@gmail.com>2020-10-02 21:21:11 +0200
commitc68f9fb87868c45fcadcc942ce4a35f10ff2f7ea (patch)
treed9056aebf73fd296afdce471b6cb9e7699eae345
parent7bb9ea911cb2e573696a91392a6a08161950ac9f (diff)
downloadsqlalchemy-c68f9fb87868c45fcadcc942ce4a35f10ff2f7ea.tar.gz
Enable pypy tests on github workflow
Fixes: #5223 Change-Id: I0952e54ed9af2952ea340be1945311376ffc1ad2
-rw-r--r--.github/workflows/run-test.yaml10
-rw-r--r--lib/sqlalchemy/orm/mapper.py2
-rw-r--r--lib/sqlalchemy/testing/plugin/pytestplugin.py2
-rw-r--r--lib/sqlalchemy/util/__init__.py1
-rw-r--r--lib/sqlalchemy/util/compat.py1
-rw-r--r--lib/sqlalchemy/util/langhelpers.py4
-rw-r--r--test/base/test_utils.py3
-rw-r--r--test/engine/test_logging.py3
-rw-r--r--test/engine/test_pool.py1
-rw-r--r--test/orm/test_deferred.py2
10 files changed, 24 insertions, 5 deletions
diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml
index 89fc24b42..61a878fdf 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 7b94bfa87..e73993e50 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 a4ace4e24..dfefd3b95 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 5fdcdf654..7ce0ce12b 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 c71deffbc..d4da21664 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 bbdd3381f..85a065e99 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 d5dece9a6..d765a4613 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 0f0c08df4..aa272c0cf 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 fbe394238..4cbdade18 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 b2a04b8ff..6be967337 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))