Skip to content

Commit a7d66ae

Browse files
authored
Add compat with pytest 8 (#1231)
1 parent 5534fd9 commit a7d66ae

5 files changed

+14
-14
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ docs = [
5454
"trio"
5555
]
5656
test = [
57-
"pytest>=7.0,<8",
57+
"pytest>=7.0,<9",
5858
"pytest-cov",
5959
"flaky",
6060
"ipyparallel",

tests/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import tempfile
88
from unittest.mock import patch
99

10+
import pytest
11+
1012
from ipykernel.kernelspec import install
1113

1214
pjoin = os.path.join
@@ -15,7 +17,8 @@
1517
patchers: list = []
1618

1719

18-
def setup():
20+
@pytest.fixture(autouse=True)
21+
def _global_setup():
1922
"""setup temporary env for tests"""
2023
global tmp
2124
tmp = tempfile.mkdtemp()
@@ -34,9 +37,7 @@ def setup():
3437

3538
# install IPython in the temp home:
3639
install(user=True)
37-
38-
39-
def teardown():
40+
yield
4041
for p in patchers:
4142
p.stop()
4243

tests/test_async.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
KC = KM = None
1212

1313

14-
def setup_function():
14+
@pytest.fixture(autouse=True)
15+
def _setup_env():
1516
"""start the global kernel (if it isn't running) and return its client"""
1617
global KM, KC
1718
KM, KC = start_new_kernel()
1819
flush_channels(KC)
19-
20-
21-
def teardown_function():
20+
yield
2221
assert KC is not None
2322
assert KM is not None
2423
KC.stop_channels()

tests/test_eventloop.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ def _get_qt_vers():
4242
_get_qt_vers()
4343

4444

45-
def setup():
45+
@pytest.fixture(autouse=True)
46+
def _setup_env():
4647
"""start the global kernel (if it isn't running) and return its client"""
4748
global KM, KC
4849
KM, KC = start_new_kernel()
4950
flush_channels(KC)
50-
51-
52-
def teardown():
51+
yield
5352
assert KM is not None
5453
assert KC is not None
5554
KC.stop_channels()

tests/test_message_spec.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
KC: BlockingKernelClient = None # type:ignore
2323

2424

25-
def setup():
25+
@pytest.fixture(autouse=True)
26+
def _setup_env():
2627
global KC
2728
KC = start_global_kernel()
2829

0 commit comments

Comments
 (0)