dev-python/tavern: Fix test failures with pytest-8

Closes: https://bugs.gentoo.org/928007
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2024-03-28 13:23:51 +01:00
parent 3be9c0ed6b
commit 9d50af73c8
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
From 3aa8cc92e474e91c2a4014b4b4ec2f1e4b2e620a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Thu, 28 Mar 2024 13:20:00 +0100
Subject: [PATCH] Replace deprecated `pytest.warns(None)`
Replace the deprecated `pytest.warns(None)` use with the `error` warning
filter, as recommended
in https://github.com/pytest-dev/pytest/issues/9404#issue-1076710891.
With this change, the tests pass with pytest-8.1.1.
---
tests/unit/test_call_run.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/unit/test_call_run.py b/tests/unit/test_call_run.py
index 30972c1a..88a72714 100644
--- a/tests/unit/test_call_run.py
+++ b/tests/unit/test_call_run.py
@@ -1,3 +1,4 @@
+import warnings
from unittest.mock import patch
import pytest
@@ -35,11 +36,10 @@ def test_run_with_cfg(self):
)
def test_doesnt_warn_about_expected_kwargs(self, expected_kwarg):
kw = {expected_kwarg: 123}
- with pytest.warns(None) as warn_rec:
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
run("", **kw)
- assert not len(warn_rec)
-
class TestParseGlobalCfg:
def test_path_correct(self):

View File

@@ -44,6 +44,11 @@ BDEPEND="
distutils_enable_tests pytest
src_prepare() {
local PATCHES=(
# https://github.com/taverntesting/tavern/pull/922
"${FILESDIR}/${P}-pytest-8.patch"
)
# strip unnecessary pins, upstream doesn't update them a lot
sed -i -E -e 's:,?<=?[0-9.]+::' pyproject.toml || die
distutils-r1_src_prepare