14
0

Accepting request 900837 from home:jayvdb:branches:devel:languages:python:django

- Switch to using pytest
- Add merged_pr_327.patch to fix mocked tests
- Update to v3.4.4

OBS-URL: https://build.opensuse.org/request/show/900837
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pymemcache?expand=0&rev=29
This commit is contained in:
2021-06-19 07:33:10 +00:00
committed by Git OBS Bridge
parent 56b5a9fcff
commit b6258bd66c
5 changed files with 106 additions and 8 deletions

63
merged_pr_327.patch Normal file
View File

@@ -0,0 +1,63 @@
From 742763658d0171598e631a72a53e331b47e281e1 Mon Sep 17 00:00:00 2001
From: Jon Parise <jon@pinterest.com>
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)

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:54fd2b7ce53671ea6df56cd747628bdfb0fc03a2e7c66e290a106e6b48c5c5ad
size 46210

3
pymemcache-3.4.4.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8185a099a4823789560cb051d98daa51e2e4d4aa9fc6027c86766892408d984e
size 48693

View File

@@ -1,3 +1,24 @@
-------------------------------------------------------------------
Sat Jun 19 02:18:02 UTC 2021 - John Vandenberg <jayvdb@gmail.com>
- 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 Tue Jun 1 10:41:18 UTC 2021 - pgajdos@suse.com

View File

@@ -20,21 +20,28 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}} %{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without python2 %bcond_without python2
Name: python-pymemcache Name: python-pymemcache
Version: 3.3.0 Version: 3.4.4
Release: 0 Release: 0
Summary: A pure Python memcached client Summary: A pure Python memcached client
License: Apache-2.0 License: Apache-2.0
Group: Development/Languages/Python Group: Development/Languages/Python
URL: https://github.com/Pinterest/pymemcache URL: https://github.com/Pinterest/pymemcache
Source: https://files.pythonhosted.org/packages/source/p/pymemcache/pymemcache-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/p/pymemcache/pymemcache-%{version}.tar.gz
BuildRequires: %{python_module mock} Patch0: https://patch-diff.githubusercontent.com/raw/pinterest/pymemcache/pull/327.patch#/merged_pr_327.patch
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module six}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: memcached
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires: python-six Requires: python-six
BuildArch: noarch 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} %if %{with python2}
BuildRequires: python-future BuildRequires: python-future
%endif %endif
@@ -56,6 +63,9 @@ pymemcache supports the following features:
%prep %prep
%setup -q -n pymemcache-%{version} %setup -q -n pymemcache-%{version}
%patch0 -p1
# Disable pytest-cov
sed -i 's/tool:pytest/tool:ignore-pytest-cov/' setup.cfg
%build %build
%python_build %python_build
@@ -65,7 +75,11 @@ pymemcache supports the following features:
%python_expand %fdupes %{buildroot}%{$python_sitelib} %python_expand %fdupes %{buildroot}%{$python_sitelib}
%check %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} %files %{python_files}
%license LICENSE.txt %license LICENSE.txt