void-packages/srcpkgs/python3-ipython_ipykernel/patches/pytest8.patch

130 lines
3.0 KiB
Diff

See: https://github.com/ipython/ipykernel/pull/1231
From 53b63239a543cc9c631db9f63612d80d4182e498 Mon Sep 17 00:00:00 2001
From: Steven Silvester <steve.silvester@mongodb.com>
Date: Mon, 8 Apr 2024 06:38:30 -0500
Subject: [PATCH 1/2] Add compat with pytest 8
---
pyproject.toml | 2 +-
tests/__init__.py | 9 +++++----
tests/test_async.py | 7 +++----
tests/test_eventloop.py | 7 +++----
4 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 909308af9..cdf265f63 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -54,7 +54,7 @@ docs = [
"trio"
]
test = [
- "pytest>=7.0",
+ "pytest>=7.0,<9",
"pytest-cov",
"flaky",
"ipyparallel",
diff --git a/tests/__init__.py b/tests/__init__.py
index 013114bd1..ee324a6fa 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -7,6 +7,8 @@
import tempfile
from unittest.mock import patch
+import pytest
+
from ipykernel.kernelspec import install
pjoin = os.path.join
@@ -15,7 +17,8 @@
patchers: list = []
-def setup():
+@pytest.fixture(autouse=True)
+def _global_setup():
"""setup temporary env for tests"""
global tmp
tmp = tempfile.mkdtemp()
@@ -34,9 +37,7 @@ def setup():
# install IPython in the temp home:
install(user=True)
-
-
-def teardown():
+ yield
for p in patchers:
p.stop()
diff --git a/tests/test_async.py b/tests/test_async.py
index 422673299..a40db4a00 100644
--- a/tests/test_async.py
+++ b/tests/test_async.py
@@ -11,14 +11,13 @@
KC = KM = None
-def setup_function():
+@pytest.fixture(autouse=True)
+def _setup_env():
"""start the global kernel (if it isn't running) and return its client"""
global KM, KC
KM, KC = start_new_kernel()
flush_channels(KC)
-
-
-def teardown_function():
+ yield
assert KC is not None
assert KM is not None
KC.stop_channels()
diff --git a/tests/test_eventloop.py b/tests/test_eventloop.py
index 34581b7fb..77596eedd 100644
--- a/tests/test_eventloop.py
+++ b/tests/test_eventloop.py
@@ -42,14 +42,13 @@ def _get_qt_vers():
_get_qt_vers()
-def setup():
+@pytest.fixture(autouse=True)
+def _setup_env():
"""start the global kernel (if it isn't running) and return its client"""
global KM, KC
KM, KC = start_new_kernel()
flush_channels(KC)
-
-
-def teardown():
+ yield
assert KM is not None
assert KC is not None
KC.stop_channels()
From b1d42cffb2466533382fb937c522cfcf14847696 Mon Sep 17 00:00:00 2001
From: Steven Silvester <steve.silvester@mongodb.com>
Date: Mon, 8 Apr 2024 06:43:26 -0500
Subject: [PATCH 2/2] fix message spec tests
---
tests/test_message_spec.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_message_spec.py b/tests/test_message_spec.py
index d9d8bb810..d98503ee7 100644
--- a/tests/test_message_spec.py
+++ b/tests/test_message_spec.py
@@ -22,7 +22,8 @@
KC: BlockingKernelClient = None # type:ignore
-def setup():
+@pytest.fixture(autouse=True)
+def _setup_env():
global KC
KC = start_global_kernel()