File tree Expand file tree Collapse file tree 3 files changed +32
-24
lines changed Expand file tree Collapse file tree 3 files changed +32
-24
lines changed Original file line number Diff line number Diff line change @@ -416,30 +416,6 @@ def coro():
416
416
417
417
class TestBaseUV (_TestBase , UVTestCase ):
418
418
419
- def test_cython_coro_is_coroutine (self ):
420
- from asyncio .coroutines import _format_coroutine
421
-
422
- coro = self .loop .create_server (object )
423
-
424
- self .assertEqual (_format_coroutine (coro ),
425
- 'Loop.create_server()' )
426
-
427
- self .assertEqual (self .loop .create_server .__qualname__ ,
428
- 'Loop.create_server' )
429
- self .assertEqual (self .loop .create_server .__name__ ,
430
- 'create_server' )
431
- self .assertTrue (asyncio .iscoroutine (coro ))
432
- fut = asyncio .ensure_future (coro , loop = self .loop )
433
- self .assertTrue (isinstance (fut , asyncio .Future ))
434
- fut .cancel ()
435
- try :
436
- self .loop .run_until_complete (fut )
437
- except asyncio .CancelledError :
438
- pass
439
-
440
- _format_coroutine (coro ) # This line checks against Cython segfault
441
- coro .close ()
442
-
443
419
def test_loop_create_future (self ):
444
420
fut = self .loop .create_future ()
445
421
self .assertTrue (isinstance (fut , asyncio .Future ))
Original file line number Diff line number Diff line change
1
+ import asyncio
2
+
3
+ from uvloop ._testbase import UVTestCase
4
+
5
+
6
+ class TestCythonIntegration (UVTestCase ):
7
+
8
+ def test_cython_coro_is_coroutine (self ):
9
+ from uvloop .loop import _test_coroutine_1
10
+ from asyncio .coroutines import _format_coroutine
11
+
12
+ coro = _test_coroutine_1 ()
13
+
14
+ self .assertEqual (_format_coroutine (coro ), '_test_coroutine_1()' )
15
+ self .assertEqual (_test_coroutine_1 .__qualname__ , '_test_coroutine_1' )
16
+ self .assertEqual (_test_coroutine_1 .__name__ , '_test_coroutine_1' )
17
+ self .assertTrue (asyncio .iscoroutine (coro ))
18
+ fut = asyncio .ensure_future (coro , loop = self .loop )
19
+ self .assertTrue (isinstance (fut , asyncio .Future ))
20
+ self .assertTrue (isinstance (fut , asyncio .Task ))
21
+ fut .cancel ()
22
+
23
+ with self .assertRaises (asyncio .CancelledError ):
24
+ self .loop .run_until_complete (fut )
25
+
26
+ _format_coroutine (coro ) # This line checks against Cython segfault
27
+ coro .close ()
Original file line number Diff line number Diff line change @@ -2271,3 +2271,8 @@ cdef __install_pymem():
2271
2271
if err < 0 :
2272
2272
__mem_installed = 0
2273
2273
raise convert_error(err)
2274
+
2275
+ # ########## Stuff for tests:
2276
+
2277
+ async def _test_coroutine_1():
2278
+ return 42
You can’t perform that action at this time.
0 commit comments