@@ -146,7 +146,7 @@ def test_tutorial_examples(readmes_mock):
146
146
147
147
148
148
@pytest .fixture
149
- async def readmes_mock (mocker , top_level_await ):
149
+ async def readmes_mock (mocker ):
150
150
fixture_infos = {
151
151
"127.0.0.1" : get_fixture_info ("KP303(UK)_1.0_1.0.3.json" , "IOT" ), # Strip
152
152
"127.0.0.2" : get_fixture_info ("HS110(EU)_1.0_1.2.5.json" , "IOT" ), # Plug
@@ -155,49 +155,3 @@ async def readmes_mock(mocker, top_level_await):
155
155
"127.0.0.5" : get_fixture_info ("HS220(US)_1.0_1.5.7.json" , "IOT" ), # Dimmer
156
156
}
157
157
yield patch_discovery (fixture_infos , mocker )
158
-
159
-
160
- @pytest .fixture
161
- def top_level_await (mocker ):
162
- """Fixture to enable top level awaits in doctests.
163
-
164
- Uses the async exec feature of python to patch the builtins xdoctest uses.
165
- See https://github.com/python/cpython/issues/78797
166
- """
167
- import ast
168
- from inspect import CO_COROUTINE
169
- from types import CodeType
170
-
171
- orig_exec = exec
172
- orig_eval = eval
173
- orig_compile = compile
174
-
175
- def patch_exec (source , globals = None , locals = None , / , ** kwargs ):
176
- if (
177
- isinstance (source , CodeType )
178
- and source .co_flags & CO_COROUTINE == CO_COROUTINE
179
- ):
180
- asyncio .run (orig_eval (source , globals , locals ))
181
- else :
182
- orig_exec (source , globals , locals , ** kwargs )
183
-
184
- def patch_eval (source , globals = None , locals = None , / , ** kwargs ):
185
- if (
186
- isinstance (source , CodeType )
187
- and source .co_flags & CO_COROUTINE == CO_COROUTINE
188
- ):
189
- return asyncio .run (orig_eval (source , globals , locals , ** kwargs ))
190
- else :
191
- return orig_eval (source , globals , locals , ** kwargs )
192
-
193
- def patch_compile (
194
- source , filename , mode , flags = 0 , dont_inherit = False , optimize = - 1 , ** kwargs
195
- ):
196
- flags |= ast .PyCF_ALLOW_TOP_LEVEL_AWAIT
197
- return orig_compile (
198
- source , filename , mode , flags , dont_inherit , optimize , ** kwargs
199
- )
200
-
201
- mocker .patch ("builtins.eval" , side_effect = patch_eval )
202
- mocker .patch ("builtins.exec" , side_effect = patch_exec )
203
- mocker .patch ("builtins.compile" , side_effect = patch_compile )
0 commit comments