commit:     bf06b7b9ea6b606bd4080deab9526d8147dd64d7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 20 15:12:23 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 20 15:20:06 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bf06b7b9

dev-python/apache-libcloud: Fix tests

Closes: https://bugs.gentoo.org/931233
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../apache-libcloud-3.8.0-r1.ebuild                | 28 +++++++++++++++-------
 .../files/apache-libcloud-3.8.0-pytest-8.2.patch   | 25 +++++++++++++++++++
 2 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/dev-python/apache-libcloud/apache-libcloud-3.8.0-r1.ebuild 
b/dev-python/apache-libcloud/apache-libcloud-3.8.0-r1.ebuild
index 26ad934cf8f7..f5aa54b9b35f 100644
--- a/dev-python/apache-libcloud/apache-libcloud-3.8.0-r1.ebuild
+++ b/dev-python/apache-libcloud/apache-libcloud-3.8.0-r1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -35,13 +35,14 @@ BDEPEND="
 
 distutils_enable_tests pytest
 
-EPYTEST_DESELECT=(
-       # Needs network access
-       
libcloud/test/compute/test_ovh.py::OvhTests::test_list_nodes_invalid_region
-       
libcloud/test/test_connection.py::BaseConnectionClassTestCase::test_connection_timeout_raised
-)
-
 src_prepare() {
+       local PATCHES=(
+               # https://github.com/apache/libcloud/pull/2014
+               "${FILESDIR}/${P}-pytest-8.2.patch"
+       )
+
+       distutils-r1_src_prepare
+
        if use examples; then
                mkdir examples || die
                mv example_*.py examples || die
@@ -49,8 +50,19 @@ src_prepare() {
 
        # needed for tests
        cp libcloud/test/secrets.py-dist libcloud/test/secrets.py || die
+}
 
-       distutils-r1_src_prepare
+python_test() {
+       local EPYTEST_DESELECT=(
+               # Needs network access
+               
libcloud/test/compute/test_ovh.py::OvhTests::test_list_nodes_invalid_region
+               
libcloud/test/test_connection.py::BaseConnectionClassTestCase::test_connection_timeout_raised
+               # TODO
+               
libcloud/test/test_init.py::TestUtils::test_init_once_and_debug_mode
+       )
+
+       local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+       epytest
 }
 
 src_install() {

diff --git 
a/dev-python/apache-libcloud/files/apache-libcloud-3.8.0-pytest-8.2.patch 
b/dev-python/apache-libcloud/files/apache-libcloud-3.8.0-pytest-8.2.patch
new file mode 100644
index 000000000000..03917b0dac75
--- /dev/null
+++ b/dev-python/apache-libcloud/files/apache-libcloud-3.8.0-pytest-8.2.patch
@@ -0,0 +1,25 @@
+From 0b69d0bf23b6c2edb1e2002f47ff2df0080e96d9 Mon Sep 17 00:00:00 2001
+From: Steve Kowalik <[email protected]>
+Date: Thu, 6 Jun 2024 12:25:15 +1000
+Subject: [PATCH] Mark MockHttp as not for collection by pytest
+
+pytest 8.2.0 contains a regression that will collect non-test classes,
+so as to be explicit about it, mark MockHttp (and therefore all of its
+children classes) as not to be collected.
+---
+ libcloud/test/__init__.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/libcloud/test/__init__.py b/libcloud/test/__init__.py
+index d45c82c84d..d0da40c74a 100644
+--- a/libcloud/test/__init__.py
++++ b/libcloud/test/__init__.py
+@@ -97,6 +97,8 @@ class MockHttp(LibcloudConnection):
+ 
+         (int status, str body, dict headers, str reason)
+     """
++    # pytest may collect this class, and we don't need or want that
++    __test__ = False
+ 
+     type = None
+     use_param = None  # will use this param to namespace the request function

Reply via email to