From 7d802503726e1849541c6313fc73c6914afb1747a26e9e99a3864f5b45ee82b4 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 22 Oct 2024 06:11:08 +0000 Subject: [PATCH] - Update to 1.8.0: * Drop support for Python 2 and <3.6, removing compatibility code. * Use stdlib unittest.mock instead of mock package. * Removed usage of path.py and path in favour of pathlib. * BREAKING CHANGE: Removed RethinkDB support, as the mirror was no longer available. * Allowed passing through HTTP headers to the server. * Fixed threading log debug messages. * Removed usage of deprecated Thread.setDaemon. * Explicitly close initial Mongo client. * Don't use context manager for CREATE DATABASE - Drop patches, included upstream: * pytest-plugins-pr186-fix-psycopg29.patch * remove-mock.patch - Refreshed remove-six-and-future.patch - Add patch fix-httpd-fixture-path.patch: * Attempt to run httpd with the correct config file - Add patch support-64-bit-pids-xvfb.patch: * Support 64 bit PIDs when running Xvfb OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-server-fixtures?expand=0&rev=20 --- fix-httpd-fixture-path.patch | 13 +++++ pytest-plugins-pr186-fix-psycopg29.patch | 43 -------------- pytest-server-fixtures-1.7.0.tar.gz | 3 - pytest-server-fixtures-1.8.0.tar.gz | 3 + python-pytest-server-fixtures.changes | 23 ++++++++ python-pytest-server-fixtures.spec | 17 +++--- remove-mock.patch | 73 ------------------------ remove-six-and-future.patch | 53 ++++++++--------- support-64-bit-pids-xvfb.patch | 16 ++++++ 9 files changed, 85 insertions(+), 159 deletions(-) create mode 100644 fix-httpd-fixture-path.patch delete mode 100644 pytest-plugins-pr186-fix-psycopg29.patch delete mode 100644 pytest-server-fixtures-1.7.0.tar.gz create mode 100644 pytest-server-fixtures-1.8.0.tar.gz delete mode 100644 remove-mock.patch create mode 100644 support-64-bit-pids-xvfb.patch diff --git a/fix-httpd-fixture-path.patch b/fix-httpd-fixture-path.patch new file mode 100644 index 0000000..c40c591 --- /dev/null +++ b/fix-httpd-fixture-path.patch @@ -0,0 +1,13 @@ +Index: pytest-server-fixtures-1.8.0/pytest_server_fixtures/httpd.py +=================================================================== +--- pytest-server-fixtures-1.8.0.orig/pytest_server_fixtures/httpd.py ++++ pytest-server-fixtures-1.8.0/pytest_server_fixtures/httpd.py +@@ -161,7 +161,7 @@ class HTTPDServer(HTTPTestServer): + + @property + def run_cmd(self): +- return [CONFIG.httpd_executable, '-f', self.config] ++ return [CONFIG.httpd_executable, '-f', str(self.config)] + + def kill(self, retries=5): + pid = self.pid diff --git a/pytest-plugins-pr186-fix-psycopg29.patch b/pytest-plugins-pr186-fix-psycopg29.patch deleted file mode 100644 index 5c7d8a9..0000000 --- a/pytest-plugins-pr186-fix-psycopg29.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 291995b3cfe60a5b30d5c6e1f3279ea40d35c7bb Mon Sep 17 00:00:00 2001 -From: Ben Greiner -Date: Sun, 17 Oct 2021 18:57:06 +0200 -Subject: [PATCH] Don't use context manager for CREATE DATABASE - -Psycopg 2.9 uses transaction blocks withing context managers, -which is not allowed for CREATE DATABASE -https://github.com/psycopg/psycopg2/issues/941 ---- - .../pytest_server_fixtures/postgres.py | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -diff --git a/pytest-server-fixtures/pytest_server_fixtures/postgres.py b/pytest-server-fixtures/pytest_server_fixtures/postgres.py -index 7c6ea33d..aeab36ad 100644 ---- a/pytest_server_fixtures/postgres.py -+++ b/pytest_server_fixtures/postgres.py -@@ -103,18 +103,22 @@ def run_cmd(self): - - def check_server_up(self): - from psycopg2 import OperationalError -+ conn = None - try: - print("Connecting to Postgres at localhost:{}".format(self.port)) -- with self.connect('postgres') as conn: -- conn.set_session(autocommit=True) -- with conn.cursor() as cursor: -- cursor.execute("CREATE DATABASE " + self.database_name) -+ conn = self.connect('postgres') -+ conn.set_session(autocommit=True) -+ with conn.cursor() as cursor: -+ cursor.execute("CREATE DATABASE " + self.database_name) - self.connection = self.connect(self.database_name) - with open(self.workspace / 'db' / 'postmaster.pid', 'r') as f: - self.pid = int(f.readline().rstrip()) - return True - except OperationalError as e: - print("Could not connect to test postgres: {}".format(e)) -+ finally: -+ if conn: -+ conn.close() - return False - - def connect(self, database=None): diff --git a/pytest-server-fixtures-1.7.0.tar.gz b/pytest-server-fixtures-1.7.0.tar.gz deleted file mode 100644 index 4123d1d..0000000 --- a/pytest-server-fixtures-1.7.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0fa5b1be6a84180e50ff91a58580e81ad3eb45828878a07942fbe384fcd86d1f -size 9801739 diff --git a/pytest-server-fixtures-1.8.0.tar.gz b/pytest-server-fixtures-1.8.0.tar.gz new file mode 100644 index 0000000..0a15a83 --- /dev/null +++ b/pytest-server-fixtures-1.8.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b1786087f481c7dfa03678090fc57ec7cff7e61f41f28960c188af219a14280 +size 9810031 diff --git a/python-pytest-server-fixtures.changes b/python-pytest-server-fixtures.changes index bad7ee0..4bd3c44 100644 --- a/python-pytest-server-fixtures.changes +++ b/python-pytest-server-fixtures.changes @@ -1,3 +1,26 @@ +------------------------------------------------------------------- +Tue Oct 22 06:08:51 UTC 2024 - Steve Kowalik + +- Update to 1.8.0: + * Drop support for Python 2 and <3.6, removing compatibility code. + * Use stdlib unittest.mock instead of mock package. + * Removed usage of path.py and path in favour of pathlib. + * BREAKING CHANGE: Removed RethinkDB support, as the mirror was no longer + available. + * Allowed passing through HTTP headers to the server. + * Fixed threading log debug messages. + * Removed usage of deprecated Thread.setDaemon. + * Explicitly close initial Mongo client. + * Don't use context manager for CREATE DATABASE +- Drop patches, included upstream: + * pytest-plugins-pr186-fix-psycopg29.patch + * remove-mock.patch +- Refreshed remove-six-and-future.patch +- Add patch fix-httpd-fixture-path.patch: + * Attempt to run httpd with the correct config file +- Add patch support-64-bit-pids-xvfb.patch: + * Support 64 bit PIDs when running Xvfb + ------------------------------------------------------------------- Wed Aug 30 05:26:54 UTC 2023 - Steve Kowalik diff --git a/python-pytest-server-fixtures.spec b/python-pytest-server-fixtures.spec index f47f07e..cdc0919 100644 --- a/python-pytest-server-fixtures.spec +++ b/python-pytest-server-fixtures.spec @@ -1,7 +1,7 @@ # # spec file for package python-pytest-server-fixtures # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,18 +17,18 @@ Name: python-pytest-server-fixtures -Version: 1.7.0 +Version: 1.8.0 Release: 0 Summary: Extensible server fixtures for pytest License: MIT URL: https://github.com/man-group/pytest-plugins Source: https://files.pythonhosted.org/packages/source/p/pytest-server-fixtures/pytest-server-fixtures-%{version}.tar.gz -# PATCH-FIX-UPSTREAM pytest-plugins-pr186-fix-psycopg29.patch -- gh#man-group/pytest-plugins#186 -Patch0: pytest-plugins-pr186-fix-psycopg29.patch -# PATCH-FIX-UPSTREAM remove-mock.patch -- gh#man-group#pytest-plugins#171 -Patch1: remove-mock.patch # PATCH-FIX-UPSTREAM gh#github.com/man-group/pytest-plugins#221 -Patch2: remove-six-and-future.patch +Patch0: remove-six-and-future.patch +# PATCH-FIX-UPSTREAM gh#man-group/pytest-plugins#249 +Patch1: fix-httpd-fixture-path.patch +# PATCH-FIX-UPSTREAM gh#man-group/pytest-plugins#250 +Patch2: support-64-bit-pids-xvfb.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools-git} BuildRequires: %{python_module setuptools} @@ -54,7 +54,6 @@ Suggests: python-psycopg2 Suggests: python-pymongo >= 3.6.0 Suggests: python-python-jenkins Suggests: python-redis -Suggests: python-rethinkdb Suggests: redis Suggests: xauth Suggests: xdpyinfo @@ -73,7 +72,6 @@ BuildRequires: %{python_module pytest} BuildRequires: %{python_module python-jenkins} BuildRequires: %{python_module redis} BuildRequires: %{python_module requests} -BuildRequires: %{python_module rethinkdb} BuildRequires: %{python_module retry} BuildRequires: apache2 BuildRequires: lsof @@ -95,7 +93,6 @@ Extensible server fixtures for pytest # Tests requiring a server rm tests/integration/test_mongo_server.py rm tests/integration/test_jenkins_server.py -rm tests/integration/test_rethink_server.py rm tests/integration/test_s3_server.py rm tests/unit/serverclass/test_kubernetes_unit.py diff --git a/remove-mock.patch b/remove-mock.patch deleted file mode 100644 index ca4df2c..0000000 --- a/remove-mock.patch +++ /dev/null @@ -1,73 +0,0 @@ -Index: a/tests/integration/test_xvfb_server.py -=================================================================== ---- a/tests/integration/test_xvfb_server.py -+++ b/tests/integration/test_xvfb_server.py -@@ -4,7 +4,11 @@ import time - - from itertools import chain, repeat - --from mock import patch -+try: -+ from unittest.mock import patch -+except ImportError: -+ from mock import patch -+ - import pytest - from pytest import raises - -Index: a/tests/unit/serverclass/test_docker_unit.py -=================================================================== ---- a/tests/unit/serverclass/test_docker_unit.py -+++ b/tests/unit/serverclass/test_docker_unit.py -@@ -1,4 +1,8 @@ --from mock import sentinel, patch, Mock -+try: -+ from unittest.mock import sentinel, patch, Mock -+except ImportError: -+ from mock import sentinel, patch, Mock -+ - - from pytest_server_fixtures.serverclass.docker import DockerServer - -Index: a/tests/unit/serverclass/test_thread_unit.py -=================================================================== ---- a/tests/unit/serverclass/test_thread_unit.py -+++ b/tests/unit/serverclass/test_thread_unit.py -@@ -1,4 +1,8 @@ --from mock import sentinel, patch, Mock -+try: -+ from unittest.mock import sentinel, patch, Mock -+except ImportError: -+ from mock import sentinel, patch, Mock -+ - - from pytest_server_fixtures import CONFIG - from pytest_server_fixtures.serverclass.thread import ThreadServer -Index: a/tests/unit/test_server_unit.py -=================================================================== ---- a/tests/unit/test_server_unit.py -+++ b/tests/unit/test_server_unit.py -@@ -1,4 +1,8 @@ --from mock import create_autospec, sentinel, call, patch, Mock -+try: -+ from unittest.mock import create_autospec, sentinel, call, patch, Mock -+except ImportError: -+ from mock import create_autospec, sentinel, call, patch, Mock -+ - - from pytest_server_fixtures.base import TestServer as _TestServer # So that pytest doesnt think this is a test case - -Index: tests/unit/test_server_v2_unit.py -=================================================================== ---- a/tests/unit/test_server_v2_unit.py -+++ b/tests/unit/test_server_v2_unit.py -@@ -1,4 +1,8 @@ --from mock import create_autospec, sentinel, call, patch, Mock -+try: -+ from unittest.mock import create_autospec, sentinel, call, patch, Mock -+except ImportError: -+ from mock import create_autospec, sentinel, call, patch, Mock -+ - - from pytest_server_fixtures.base2 import TestServerV2 as _TestServerV2 # TODO: why as _TestServerV2? - diff --git a/remove-six-and-future.patch b/remove-six-and-future.patch index 9bdbe9a..f458d4b 100644 --- a/remove-six-and-future.patch +++ b/remove-six-and-future.patch @@ -14,10 +14,10 @@ crutches like six and future. pytest-server-fixtures/setup.py | 2 -- 6 files changed, 10 insertions(+), 19 deletions(-) -Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/base.py +Index: pytest-server-fixtures-1.8.0/pytest_server_fixtures/base.py =================================================================== ---- pytest-server-fixtures-1.7.0.orig/pytest_server_fixtures/base.py -+++ pytest-server-fixtures-1.7.0/pytest_server_fixtures/base.py +--- pytest-server-fixtures-1.8.0.orig/pytest_server_fixtures/base.py ++++ pytest-server-fixtures-1.8.0/pytest_server_fixtures/base.py @@ -14,8 +14,6 @@ import logging import random import errno @@ -27,26 +27,19 @@ Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/base.py from pytest_server_fixtures import CONFIG from pytest_shutil.workspace import Workspace -@@ -103,13 +101,13 @@ class ProcessReader(threading.Thread): - self.stderr = stderr - self.process = process - self.stream = stream -- super(ProcessReader, self).__init__() -+ super().__init__() - self.setDaemon(True) - +@@ -112,7 +110,7 @@ class ProcessReader(threading.Thread): def run(self): while self.process.poll() is None: l = self.stream.readline() - if not isinstance(l, string_types): -+ if not isinstance(l, six): ++ if not isinstance(l, str): l = l.decode('utf-8') if l.strip(): -Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/http.py +Index: pytest-server-fixtures-1.8.0/pytest_server_fixtures/http.py =================================================================== ---- pytest-server-fixtures-1.7.0.orig/pytest_server_fixtures/http.py -+++ pytest-server-fixtures-1.7.0/pytest_server_fixtures/http.py +--- pytest-server-fixtures-1.8.0.orig/pytest_server_fixtures/http.py ++++ pytest-server-fixtures-1.8.0/pytest_server_fixtures/http.py @@ -1,5 +1,4 @@ -from __future__ import print_function - @@ -71,19 +64,19 @@ Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/http.py time.sleep(int(i) / 10) pass raise e -@@ -107,7 +105,7 @@ class HTTPTestServer(TestServer): +@@ -109,7 +107,7 @@ class HTTPTestServer(TestServer): with self.handle_proxy(): - returned = requests.post('http://%s:%d/%s' % (self.hostname, self.port, path), data=data) + returned = requests.post('http://%s:%d/%s' % (self.hostname, self.port, path), data=data, headers=headers) return returned.json() if as_json else returned - except (http_client.BadStatusLine, requests.ConnectionError) as e: + except (http.client.BadStatusLine, requests.ConnectionError) as e: time.sleep(int(i) / 10) pass raise e -Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/jenkins.py +Index: pytest-server-fixtures-1.8.0/pytest_server_fixtures/jenkins.py =================================================================== ---- pytest-server-fixtures-1.7.0.orig/pytest_server_fixtures/jenkins.py -+++ pytest-server-fixtures-1.7.0/pytest_server_fixtures/jenkins.py +--- pytest-server-fixtures-1.8.0.orig/pytest_server_fixtures/jenkins.py ++++ pytest-server-fixtures-1.8.0/pytest_server_fixtures/jenkins.py @@ -9,7 +9,6 @@ import os.path import shutil @@ -101,10 +94,10 @@ Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/jenkins.py plugins = [plugins] errors = [] -Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/postgres.py +Index: pytest-server-fixtures-1.8.0/pytest_server_fixtures/postgres.py =================================================================== ---- pytest-server-fixtures-1.7.0.orig/pytest_server_fixtures/postgres.py -+++ pytest-server-fixtures-1.7.0/pytest_server_fixtures/postgres.py +--- pytest-server-fixtures-1.8.0.orig/pytest_server_fixtures/postgres.py ++++ pytest-server-fixtures-1.8.0/pytest_server_fixtures/postgres.py @@ -8,7 +8,6 @@ import subprocess import errno @@ -131,10 +124,10 @@ Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/postgres.py print(msg) self._fail(msg) -Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/s3.py +Index: pytest-server-fixtures-1.8.0/pytest_server_fixtures/s3.py =================================================================== ---- pytest-server-fixtures-1.7.0.orig/pytest_server_fixtures/s3.py -+++ pytest-server-fixtures-1.7.0/pytest_server_fixtures/s3.py +--- pytest-server-fixtures-1.8.0.orig/pytest_server_fixtures/s3.py ++++ pytest-server-fixtures-1.8.0/pytest_server_fixtures/s3.py @@ -11,7 +11,6 @@ import logging import os @@ -160,11 +153,11 @@ Index: pytest-server-fixtures-1.7.0/pytest_server_fixtures/s3.py + str(self.datadir), ] return cmdargs -Index: pytest-server-fixtures-1.7.0/setup.py +Index: pytest-server-fixtures-1.8.0/setup.py =================================================================== ---- pytest-server-fixtures-1.7.0.orig/setup.py -+++ pytest-server-fixtures-1.7.0/setup.py -@@ -25,8 +25,6 @@ classifiers = [ +--- pytest-server-fixtures-1.8.0.orig/setup.py ++++ pytest-server-fixtures-1.8.0/setup.py +@@ -20,8 +20,6 @@ classifiers = [ install_requires = ['pytest', 'pytest-shutil', 'pytest-fixture-config', diff --git a/support-64-bit-pids-xvfb.patch b/support-64-bit-pids-xvfb.patch new file mode 100644 index 0000000..e611946 --- /dev/null +++ b/support-64-bit-pids-xvfb.patch @@ -0,0 +1,16 @@ +Index: pytest-server-fixtures-1.8.0/pytest_server_fixtures/xvfb.py +=================================================================== +--- pytest-server-fixtures-1.8.0.orig/pytest_server_fixtures/xvfb.py ++++ pytest-server-fixtures-1.8.0/pytest_server_fixtures/xvfb.py +@@ -43,7 +43,10 @@ class XvfbServer(object): + + def __init__(self): + tmpdir = mkdtemp(prefix='XvfbServer.', dir=Workspace.get_base_tempdir()) +- for servernum in range(os.getpid(), 65536): ++ pid_max = 65536 ++ with open('/proc/sys/kernel/pid_max') as pid_max_file: ++ pid_max = int(pid_max_file.read()) ++ for servernum in range(os.getpid(), pid_max): + if os.path.exists('/tmp/.X{0}-lock'.format(servernum)): + continue + self.display = ':' + str(servernum)