diff --git a/merged_pr_327.patch b/merged_pr_327.patch new file mode 100644 index 0000000..ae8f3e2 --- /dev/null +++ b/merged_pr_327.patch @@ -0,0 +1,63 @@ +From 742763658d0171598e631a72a53e331b47e281e1 Mon Sep 17 00:00:00 2001 +From: Jon Parise +Date: Fri, 18 Jun 2021 11:56:06 -0700 +Subject: [PATCH] Provide a mock implementation of socket.getaddrinfo + +9551dfd0 introduced a call to socket.getaddrinfo() to support IPv6, but +we never added an implementation of that function to MockSocketModule. +This resulted in some tests making "live" socket.getaddrinfo() calls +because of the default MockSocketModule.__getattr__ implementation +(which we need to forward other module attribute lookups). +--- + pymemcache/test/test_client.py | 24 ++++++++++++++++++++---- + 1 file changed, 20 insertions(+), 4 deletions(-) + +diff --git a/pymemcache/test/test_client.py b/pymemcache/test/test_client.py +index 24ecab2..93d327c 100644 +--- a/pymemcache/test/test_client.py ++++ b/pymemcache/test/test_client.py +@@ -40,6 +40,11 @@ + from pymemcache.test.utils import MockMemcacheClient + + ++# TODO: Use ipaddress module when dropping support for Python < 3.3 ++def is_ipv6(address): ++ return re.match(r'^[0-9a-f:]+$', address) ++ ++ + class MockSocket(object): + def __init__(self, recv_bufs, connect_failure=None, close_failure=None): + self.recv_bufs = collections.deque(recv_bufs) +@@ -53,10 +58,8 @@ def __init__(self, recv_bufs, connect_failure=None, close_failure=None): + + @property + def family(self): +- # TODO: Use ipaddress module when dropping support for Python < 3.3 +- ipv6_re = re.compile(r'^[0-9a-f:]+$') +- is_ipv6 = any(ipv6_re.match(c[0]) for c in self.connections) +- return socket.AF_INET6 if is_ipv6 else socket.AF_INET ++ any_ipv6 = any(is_ipv6(c[0]) for c in self.connections) ++ return socket.AF_INET6 if any_ipv6 else socket.AF_INET + + def sendall(self, value): + self.send_bufs.append(value) +@@ -115,6 +118,19 @@ def socket(self, family, type, proto=0, fileno=None): + self.sockets.append(socket) + return socket + ++ def getaddrinfo(self, host, port, family=0, type=0, proto=0, flags=0): ++ family = family or ( ++ socket.AF_INET6 if is_ipv6(host) else socket.AF_INET ++ ) ++ type = type or socket.SOCK_STREAM ++ proto = proto or socket.IPPROTO_TCP ++ sockaddr = ( ++ ('::1', 11211, 0, 0) ++ if family == socket.AF_INET6 ++ else ('127.0.0.1', 11211) ++ ) ++ return [(family, type, proto, '', sockaddr)] ++ + def __getattr__(self, name): + return getattr(socket, name) + diff --git a/pymemcache-3.3.0.tar.gz b/pymemcache-3.3.0.tar.gz deleted file mode 100644 index c2d736b..0000000 --- a/pymemcache-3.3.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:54fd2b7ce53671ea6df56cd747628bdfb0fc03a2e7c66e290a106e6b48c5c5ad -size 46210 diff --git a/pymemcache-3.4.4.tar.gz b/pymemcache-3.4.4.tar.gz new file mode 100644 index 0000000..e0d93ab --- /dev/null +++ b/pymemcache-3.4.4.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8185a099a4823789560cb051d98daa51e2e4d4aa9fc6027c86766892408d984e +size 48693 diff --git a/python-pymemcache.changes b/python-pymemcache.changes index 19e75f9..be1dba2 100644 --- a/python-pymemcache.changes +++ b/python-pymemcache.changes @@ -1,3 +1,24 @@ +------------------------------------------------------------------- +Sat Jun 19 02:18:02 UTC 2021 - John Vandenberg + +- Switch to using pytest +- Add merged_pr_327.patch to fix mocked tests +- Update to v3.4.4 + * Idle connections will be removed from the pool after pool_idle_timeout +- from v3.4.3 + * Fix `HashClient.{get,set}_many()` with UNIX sockets. +- from v3.4.2 + * Remove trailing space for commands that don't take arguments, such + as `stats`. This was a violation of the memcached protocol. +- from v3.4.1 + * CAS operations will now raise MemcacheIllegalInputError when + None is given as the `cas` value. +- from v3.4.0 + * Added IPv6 support for TCP socket connections. Note that IPv6 may + be used in preference to IPv4 when passing a domain name as the + host if an IPv6 address can be resolved for that domain. + * `HashClient` now supports UNIX sockets. + ------------------------------------------------------------------- Tue Jun 1 10:41:18 UTC 2021 - pgajdos@suse.com diff --git a/python-pymemcache.spec b/python-pymemcache.spec index a186ebe..e18bc7a 100644 --- a/python-pymemcache.spec +++ b/python-pymemcache.spec @@ -20,21 +20,28 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without python2 Name: python-pymemcache -Version: 3.3.0 +Version: 3.4.4 Release: 0 Summary: A pure Python memcached client License: Apache-2.0 Group: Development/Languages/Python URL: https://github.com/Pinterest/pymemcache Source: https://files.pythonhosted.org/packages/source/p/pymemcache/pymemcache-%{version}.tar.gz -BuildRequires: %{python_module mock} -BuildRequires: %{python_module pytest} +Patch0: https://patch-diff.githubusercontent.com/raw/pinterest/pymemcache/pull/327.patch#/merged_pr_327.patch BuildRequires: %{python_module setuptools} -BuildRequires: %{python_module six} BuildRequires: fdupes +BuildRequires: memcached BuildRequires: python-rpm-macros Requires: python-six BuildArch: noarch +# SECTION test requirements +BuildRequires: %{python_module gevent} +BuildRequires: %{python_module mock} +BuildRequires: %{python_module pylibmc} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module python-memcached} +BuildRequires: %{python_module six} +# /SECTION %if %{with python2} BuildRequires: python-future %endif @@ -56,6 +63,9 @@ pymemcache supports the following features: %prep %setup -q -n pymemcache-%{version} +%patch0 -p1 +# Disable pytest-cov +sed -i 's/tool:pytest/tool:ignore-pytest-cov/' setup.cfg %build %python_build @@ -65,7 +75,11 @@ pymemcache supports the following features: %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%pyunittest discover -v +%{_sbindir}/memcached & +# TLS tests depend on setting up a memcached equivalent to +# https://github.com/scoriacorp/docker-tls-memcached +%pytest -rs -k 'not tls' + %files %{python_files} %license LICENSE.txt