17
0

Compare commits

8 Commits

Author SHA256 Message Date
9b5844dd24 Skip httpd integration tests
We can't run these tests with abuild user in build environment.
2025-11-04 12:07:34 +01:00
8d6cd3aefd Accepting request 1293183 from devel:languages:python:pytest
- remove python-jenkins from test requirements (jenkins tests
  are not run)

- Don't use %_libdir to discover where apache2 is living.
- Drop mock BuildRequires, it is not required.
- use pytest macro

OBS-URL: https://build.opensuse.org/request/show/1293183
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-server-fixtures?expand=0&rev=12
2025-07-15 14:44:13 +00:00
fef9699079 - remove python-jenkins from test requirements (jenkins tests
are not run)
- Don't use %_libdir to discover where apache2 is living.
- Drop mock BuildRequires, it is not required.
- use pytest macro

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-server-fixtures?expand=0&rev=25
2025-07-14 15:24:46 +00:00
03529dcbfb Accepting request 1246294 from devel:languages:python:pytest
- Don't use %_libdir to discover where apache2 is living. 

- Update 1.8.1:
  * Correct httpd command line
  * Minor bugfix now that workspace.workspace is a Path object.
- Drop patch fix-httpd-fixture-path.patch, now included.

OBS-URL: https://build.opensuse.org/request/show/1246294
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-server-fixtures?expand=0&rev=11
2025-02-17 19:54:55 +00:00
954bc71d44 - Don't use %_libdir to discover where apache2 is living.
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-server-fixtures?expand=0&rev=23
2025-02-17 03:15:08 +00:00
971d40e72b - Update 1.8.1:
* Correct httpd command line
  * Minor bugfix now that workspace.workspace is a Path object.
- Drop patch fix-httpd-fixture-path.patch, now included.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-server-fixtures?expand=0&rev=22
2025-02-04 04:14:37 +00:00
56d078adc1 Accepting request 1216912 from devel:languages:python:pytest
- 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/request/show/1216912
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-server-fixtures?expand=0&rev=10
2024-10-22 12:53:00 +00:00
7d80250372 - 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
2024-10-22 06:11:08 +00:00
8 changed files with 102 additions and 165 deletions

View File

@@ -1,43 +0,0 @@
From 291995b3cfe60a5b30d5c6e1f3279ea40d35c7bb Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
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):

View File

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

View File

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

View File

@@ -1,3 +1,51 @@
-------------------------------------------------------------------
Tue Nov 4 11:06:31 UTC 2025 - Daniel Garcia <daniel.garcia@suse.com>
- Skip httpd integration tests, we can't run these tests with abuild
user in build environment.
-------------------------------------------------------------------
Mon Jul 14 15:24:24 UTC 2025 - Dirk Müller <dmueller@suse.com>
- remove python-jenkins from test requirements (jenkins tests
are not run)
-------------------------------------------------------------------
Mon Feb 17 03:14:35 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Don't use %_libdir to discover where apache2 is living.
-------------------------------------------------------------------
Tue Feb 4 04:07:03 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Update 1.8.1:
* Correct httpd command line
* Minor bugfix now that workspace.workspace is a Path object.
- Drop patch fix-httpd-fixture-path.patch, now included.
-------------------------------------------------------------------
Tue Oct 22 06:08:51 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- 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 <steven.kowalik@suse.com>
@@ -38,7 +86,7 @@ Thu Apr 21 20:21:33 UTC 2022 - Ben Greiner <code@bnavigator.de>
-------------------------------------------------------------------
Mon Mar 21 04:29:05 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Drop mock BuildRequires, it is not required.
- Drop mock BuildRequires, it is not required.
-------------------------------------------------------------------
Sun Oct 17 17:03:09 UTC 2021 - Ben Greiner <code@bnavigator.de>
@@ -60,7 +108,7 @@ Fri May 29 09:58:44 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
-------------------------------------------------------------------
Sat Dec 28 17:15:33 UTC 2019 - Ondřej Súkup <mimi.vx@gmail.com>
- use pytest macro
- use pytest macro
-------------------------------------------------------------------
Tue Sep 10 08:09:04 UTC 2019 - John Vandenberg <jayvdb@gmail.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-pytest-server-fixtures
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2025 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,16 @@
Name: python-pytest-server-fixtures
Version: 1.7.0
Version: 1.8.1
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#250
Patch1: support-64-bit-pids-xvfb.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools-git}
BuildRequires: %{python_module setuptools}
@@ -52,9 +50,7 @@ Suggests: python-docker
Suggests: python-kubernetes
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
@@ -70,10 +66,8 @@ BuildRequires: %{python_module pymongo >= 3.6.0}
BuildRequires: %{python_module pytest-fixture-config}
BuildRequires: %{python_module pytest-shutil}
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 +89,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
@@ -111,11 +104,14 @@ sed -i '/mod_mpm_prefork.so/d' pytest_server_fixtures/httpd.py
%check
export PATH=$HOME/bin:$PATH:%{_sbindir}
export SERVER_FIXTURES_HTTPD_MODULES=%{_libdir}/apache2/
export SERVER_FIXTURES_HTTPD_MODULES=$(ls -1d /usr/lib*/apache2)
export SERVER_FIXTURES_HTTPD=httpd
export SERVER_FIXTURES_REDIS=%{_sbindir}/redis-server
# gh#man-group/pytest-plugins#177
%pytest -k 'not test_init'
donttest="test_init"
# httpd -f can't be run as abuild user
# mkdir: cannot create directory /etc/apache2/sysconfig.d/: Permission denied
%pytest -k "not ($donttest)" --ignore tests/integration/test_httpd_proxy_server.py
%files %{python_files}
%doc CHANGES.md README.md

View File

@@ -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?

View File

@@ -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',

View File

@@ -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)