- tests actually use pytest-asyncio, otherwise they break even with the patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:jupyter/python-ipython?expand=0&rev=147
82 lines
2.7 KiB
Diff
82 lines
2.7 KiB
Diff
From 9dc9414beec774e0857d655299231fb8e311d9b8 Mon Sep 17 00:00:00 2001
|
|
From: M Bussonnier <bussonniermatthias@gmail.com>
|
|
Date: Sat, 22 Feb 2025 19:51:26 +0100
|
|
Subject: [PATCH] Fix a number of pytest warnings
|
|
|
|
---
|
|
tests/conftest.py | 13 -------------
|
|
tests/test_embed.py | 2 +-
|
|
tests/test_interactiveshell.py | 4 +---
|
|
tests/test_magic.py | 5 +++++
|
|
tests/test_run.py | 6 +++---
|
|
5 files changed, 10 insertions(+), 20 deletions(-)
|
|
|
|
Index: ipython-8.37.0/IPython/conftest.py
|
|
===================================================================
|
|
--- ipython-8.37.0.orig/IPython/conftest.py
|
|
+++ ipython-8.37.0/IPython/conftest.py
|
|
@@ -14,19 +14,6 @@ pytest.register_assert_rewrite("IPython.
|
|
from .testing import tools
|
|
|
|
|
|
-def pytest_collection_modifyitems(items):
|
|
- """This function is automatically run by pytest passing all collected test
|
|
- functions.
|
|
-
|
|
- We use it to add asyncio marker to all async tests and assert we don't use
|
|
- test functions that are async generators which wouldn't make sense.
|
|
- """
|
|
- for item in items:
|
|
- if inspect.iscoroutinefunction(item.obj):
|
|
- item.add_marker("asyncio")
|
|
- assert not inspect.isasyncgenfunction(item.obj)
|
|
-
|
|
-
|
|
def get_ipython():
|
|
from .terminal.interactiveshell import TerminalInteractiveShell
|
|
if TerminalInteractiveShell._instance:
|
|
Index: ipython-8.37.0/IPython/core/tests/test_magic.py
|
|
===================================================================
|
|
--- ipython-8.37.0.orig/IPython/core/tests/test_magic.py
|
|
+++ ipython-8.37.0/IPython/core/tests/test_magic.py
|
|
@@ -1198,6 +1198,7 @@ def test_script_out_err():
|
|
assert ip.user_ns["error"].strip() == "hello"
|
|
|
|
|
|
+@pytest.mark.asyncio
|
|
async def test_script_bg_out():
|
|
ip = get_ipython()
|
|
ip.run_cell_magic("script", f"--bg --out output {sys.executable}", "print('hi')")
|
|
@@ -1205,6 +1206,7 @@ async def test_script_bg_out():
|
|
assert ip.user_ns["output"].at_eof()
|
|
|
|
|
|
+@pytest.mark.asyncio
|
|
async def test_script_bg_err():
|
|
ip = get_ipython()
|
|
ip.run_cell_magic(
|
|
@@ -1216,6 +1218,7 @@ async def test_script_bg_err():
|
|
assert ip.user_ns["error"].at_eof()
|
|
|
|
|
|
+@pytest.mark.asyncio
|
|
async def test_script_bg_out_err():
|
|
ip = get_ipython()
|
|
ip.run_cell_magic(
|
|
@@ -1235,6 +1238,7 @@ async def test_script_bg_out_err():
|
|
assert ip.user_ns["error"].at_eof()
|
|
|
|
|
|
+@pytest.mark.asyncio
|
|
async def test_script_bg_proc():
|
|
ip = get_ipython()
|
|
ip.run_cell_magic(
|
|
@@ -1269,6 +1273,7 @@ def test_script_defaults():
|
|
assert cmd in ip.magics_manager.magics["cell"]
|
|
|
|
|
|
+@pytest.mark.asyncio
|
|
async def test_script_streams_continiously(capsys):
|
|
ip = get_ipython()
|
|
# Windows is slow to start up a thread on CI
|