File tree Expand file tree Collapse file tree 5 files changed +13
-7
lines changed Expand file tree Collapse file tree 5 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,6 @@ def setUp(self):
29
29
self .loop .set_exception_handler (self .loop_exception_handler )
30
30
self .__unhandled_exceptions = []
31
31
32
- # Disable `_get_running_loop`.
33
- self ._old_get_running_loop = asyncio .events ._get_running_loop
34
- asyncio .events ._get_running_loop = lambda : None
35
-
36
32
def tearDown (self ):
37
33
try :
38
34
self .loop .close ()
@@ -43,7 +39,6 @@ def tearDown(self):
43
39
self .fail ('unexpected calls to loop.call_exception_handler()' )
44
40
45
41
finally :
46
- asyncio .events ._get_running_loop = self ._old_get_running_loop
47
42
asyncio .set_event_loop (None )
48
43
self .loop = None
49
44
Original file line number Diff line number Diff line change @@ -918,6 +918,8 @@ def _get_future_cls(self):
918
918
return futures ._PyFuture
919
919
920
920
921
+ @unittest .skipUnless (hasattr (futures , '_CFuture' ),
922
+ 'requires the C _asyncio module' )
921
923
class CFutureInheritanceTests (BaseFutureInheritanceTests ,
922
924
test_utils .TestCase ):
923
925
def _get_future_cls (self ):
Original file line number Diff line number Diff line change @@ -278,6 +278,7 @@ async def client(addr):
278
278
279
279
# No garbage is left if SSL is closed uncleanly
280
280
client_context = weakref .ref (client_context )
281
+ support .gc_collect ()
281
282
self .assertIsNone (client_context ())
282
283
283
284
def test_create_connection_memory_leak (self ):
@@ -341,6 +342,7 @@ async def client(addr):
341
342
# No garbage is left for SSL client from loop.create_connection, even
342
343
# if user stores the SSLTransport in corresponding protocol instance
343
344
client_context = weakref .ref (client_context )
345
+ support .gc_collect ()
344
346
self .assertIsNone (client_context ())
345
347
346
348
def test_start_tls_client_buf_proto_1 (self ):
@@ -640,6 +642,7 @@ async def client(addr):
640
642
# The 10s handshake timeout should be cancelled to free related
641
643
# objects without really waiting for 10s
642
644
client_sslctx = weakref .ref (client_sslctx )
645
+ support .gc_collect ()
643
646
self .assertIsNone (client_sslctx ())
644
647
645
648
def test_create_connection_ssl_slow_handshake (self ):
Original file line number Diff line number Diff line change @@ -3275,15 +3275,18 @@ class GenericTaskTests(test_utils.TestCase):
3275
3275
def test_future_subclass (self ):
3276
3276
self .assertTrue (issubclass (asyncio .Task , asyncio .Future ))
3277
3277
3278
+ @support .cpython_only
3278
3279
def test_asyncio_module_compiled (self ):
3279
3280
# Because of circular imports it's easy to make _asyncio
3280
3281
# module non-importable. This is a simple test that will
3281
3282
# fail on systems where C modules were successfully compiled
3282
- # (hence the test for _functools), but _asyncio somehow didn't.
3283
+ # (hence the test for _functools etc ), but _asyncio somehow didn't.
3283
3284
try :
3284
3285
import _functools
3286
+ import _json
3287
+ import _pickle
3285
3288
except ImportError :
3286
- pass
3289
+ self . skipTest ( 'C modules are not available' )
3287
3290
else :
3288
3291
try :
3289
3292
import _asyncio
Original file line number Diff line number Diff line change
1
+ Made tests relying on the :mod: `_asyncio ` C extension module optional to
2
+ allow running on alternative Python implementations. Patch by Serhiy
3
+ Storchaka.
You can’t perform that action at this time.
0 commit comments