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 @@ -2875,15 +2875,18 @@ class GenericTaskTests(test_utils.TestCase):
2875
2875
def test_future_subclass (self ):
2876
2876
self .assertTrue (issubclass (asyncio .Task , asyncio .Future ))
2877
2877
2878
+ @support .cpython_only
2878
2879
def test_asyncio_module_compiled (self ):
2879
2880
# Because of circular imports it's easy to make _asyncio
2880
2881
# module non-importable. This is a simple test that will
2881
2882
# fail on systems where C modules were successfully compiled
2882
- # (hence the test for _functools), but _asyncio somehow didn't.
2883
+ # (hence the test for _functools etc ), but _asyncio somehow didn't.
2883
2884
try :
2884
2885
import _functools
2886
+ import _json
2887
+ import _pickle
2885
2888
except ImportError :
2886
- pass
2889
+ self . skipTest ( 'C modules are not available' )
2887
2890
else :
2888
2891
try :
2889
2892
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