Skip to content

Commit

Permalink
Add compat with pytest 8 (ipython#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Apr 8, 2024
1 parent 5534fd9 commit a7d66ae
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ docs = [
"trio"
]
test = [
"pytest>=7.0,<8",
"pytest>=7.0,<9",
"pytest-cov",
"flaky",
"ipyparallel",
Expand Down
9 changes: 5 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import tempfile
from unittest.mock import patch

import pytest

from ipykernel.kernelspec import install

pjoin = os.path.join
Expand All @@ -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()
Expand All @@ -34,9 +37,7 @@ def setup():

# install IPython in the temp home:
install(user=True)


def teardown():
yield
for p in patchers:
p.stop()

Expand Down
7 changes: 3 additions & 4 deletions tests/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions tests/test_eventloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_message_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
KC: BlockingKernelClient = None # type:ignore


def setup():
@pytest.fixture(autouse=True)
def _setup_env():
global KC
KC = start_global_kernel()

Expand Down

0 comments on commit a7d66ae

Please sign in to comment.