File: 0003-pytest-asyncio-marks.patch

package info (click to toggle)
ipython 8.35.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,900 kB
  • sloc: python: 42,442; sh: 376; makefile: 243
file content (79 lines) | stat: -rw-r--r-- 2,510 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From: M Bussonnier <bussonniermatthias@gmail.com>
Date: Sat, 22 Feb 2025 19:51:26 +0100
Subject: Fix a number of pytest warnings

Origin: backport, https://github.com/ipython/ipython/pull/14759
Last-Update: 2025-09-04
---
 IPython/conftest.py              | 13 -------------
 IPython/core/tests/test_magic.py |  5 +++++
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/IPython/conftest.py b/IPython/conftest.py
index abf6131..4f688e6 100644
--- a/IPython/conftest.py
+++ b/IPython/conftest.py
@@ -14,19 +14,6 @@
 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:
diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py
index 4e16700..9534bd8 100644
--- a/IPython/core/tests/test_magic.py
+++ b/IPython/core/tests/test_magic.py
@@ -1190,6 +1190,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')")
@@ -1197,6 +1198,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(
@@ -1208,6 +1210,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(
@@ -1227,6 +1230,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(
@@ -1261,6 +1265,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