|
5 | 5 | from functools import cached_property |
6 | 6 | from functools import partial |
7 | 7 | from functools import wraps |
8 | | -import sys |
9 | 8 | from typing import TYPE_CHECKING |
10 | 9 |
|
11 | 10 | from _pytest.compat import _PytestWrapper |
12 | 11 | from _pytest.compat import assert_never |
13 | 12 | from _pytest.compat import get_real_func |
14 | | -from _pytest.compat import is_generator |
15 | 13 | from _pytest.compat import safe_getattr |
16 | 14 | from _pytest.compat import safe_isclass |
17 | 15 | from _pytest.outcomes import OutcomeException |
18 | | -from _pytest.pytester import Pytester |
19 | 16 | import pytest |
20 | 17 |
|
21 | 18 |
|
22 | 19 | if TYPE_CHECKING: |
23 | 20 | from typing_extensions import Literal |
24 | 21 |
|
25 | 22 |
|
26 | | -def test_is_generator() -> None: |
27 | | - def zap(): |
28 | | - yield # pragma: no cover |
29 | | - |
30 | | - def foo(): |
31 | | - pass # pragma: no cover |
32 | | - |
33 | | - assert is_generator(zap) |
34 | | - assert not is_generator(foo) |
35 | | - |
36 | | - |
37 | 23 | def test_real_func_loop_limit() -> None: |
38 | 24 | class Evil: |
39 | 25 | def __init__(self): |
@@ -95,65 +81,6 @@ def foo(x): |
95 | 81 | assert get_real_func(partial(foo)) is foo |
96 | 82 |
|
97 | 83 |
|
98 | | -@pytest.mark.skipif(sys.version_info >= (3, 11), reason="coroutine removed") |
99 | | -def test_is_generator_asyncio(pytester: Pytester) -> None: |
100 | | - pytester.makepyfile( |
101 | | - """ |
102 | | - from _pytest.compat import is_generator |
103 | | - import asyncio |
104 | | - @asyncio.coroutine |
105 | | - def baz(): |
106 | | - yield from [1,2,3] |
107 | | -
|
108 | | - def test_is_generator_asyncio(): |
109 | | - assert not is_generator(baz) |
110 | | - """ |
111 | | - ) |
112 | | - # avoid importing asyncio into pytest's own process, |
113 | | - # which in turn imports logging (#8) |
114 | | - result = pytester.runpytest_subprocess() |
115 | | - result.stdout.fnmatch_lines(["*1 passed*"]) |
116 | | - |
117 | | - |
118 | | -def test_is_generator_async_syntax(pytester: Pytester) -> None: |
119 | | - pytester.makepyfile( |
120 | | - """ |
121 | | - from _pytest.compat import is_generator |
122 | | - def test_is_generator_py35(): |
123 | | - async def foo(): |
124 | | - await foo() |
125 | | -
|
126 | | - async def bar(): |
127 | | - pass |
128 | | -
|
129 | | - assert not is_generator(foo) |
130 | | - assert not is_generator(bar) |
131 | | - """ |
132 | | - ) |
133 | | - result = pytester.runpytest() |
134 | | - result.stdout.fnmatch_lines(["*1 passed*"]) |
135 | | - |
136 | | - |
137 | | -def test_is_generator_async_gen_syntax(pytester: Pytester) -> None: |
138 | | - pytester.makepyfile( |
139 | | - """ |
140 | | - from _pytest.compat import is_generator |
141 | | - def test_is_generator(): |
142 | | - async def foo(): |
143 | | - yield |
144 | | - await foo() |
145 | | -
|
146 | | - async def bar(): |
147 | | - yield |
148 | | -
|
149 | | - assert not is_generator(foo) |
150 | | - assert not is_generator(bar) |
151 | | - """ |
152 | | - ) |
153 | | - result = pytester.runpytest() |
154 | | - result.stdout.fnmatch_lines(["*1 passed*"]) |
155 | | - |
156 | | - |
157 | 84 | class ErrorsHelper: |
158 | 85 | @property |
159 | 86 | def raise_baseexception(self): |
|
0 commit comments