diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-08-26 13:41:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 13:41:29 (GMT) |
commit | 9f814beadb3ee2c7b37e949a2acf72117a449ffd (patch) | |
tree | 6ffd903ea16d6cbb4f86e89cc0eea6d8554c52ae /Lib/test | |
parent | 32c1caa87f68a650f2d009a589a1db30484499cb (diff) | |
download | cpython-9f814beadb3ee2c7b37e949a2acf72117a449ffd.zip cpython-9f814beadb3ee2c7b37e949a2acf72117a449ffd.tar.gz cpython-9f814beadb3ee2c7b37e949a2acf72117a449ffd.tar.bz2 |
bpo-45011: Fix test_asyncio without C module _asyncio (GH-27968)
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 7dc505b8655b3e48b93a4274dfd26e5856d9c64f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/functional.py | 5 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_futures.py | 2 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_sslproto.py | 3 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 7 |
4 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_asyncio/functional.py b/Lib/test/test_asyncio/functional.py index 74490a8..d19c7a6 100644 --- a/Lib/test/test_asyncio/functional.py +++ b/Lib/test/test_asyncio/functional.py @@ -29,10 +29,6 @@ class FunctionalTestCaseMixin: self.loop.set_exception_handler(self.loop_exception_handler) self.__unhandled_exceptions = [] - # Disable `_get_running_loop`. - self._old_get_running_loop = asyncio.events._get_running_loop - asyncio.events._get_running_loop = lambda: None - def tearDown(self): try: self.loop.close() @@ -43,7 +39,6 @@ class FunctionalTestCaseMixin: self.fail('unexpected calls to loop.call_exception_handler()') finally: - asyncio.events._get_running_loop = self._old_get_running_loop asyncio.set_event_loop(None) self.loop = None diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index fe3d442..42b9499 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -918,6 +918,8 @@ class PyFutureInheritanceTests(BaseFutureInheritanceTests, return futures._PyFuture +@unittest.skipUnless(hasattr(futures, '_CFuture'), + 'requires the C _asyncio module') class CFutureInheritanceTests(BaseFutureInheritanceTests, test_utils.TestCase): def _get_future_cls(self): diff --git a/Lib/test/test_asyncio/test_sslproto.py b/Lib/test/test_asyncio/test_sslproto.py index e87863e..a47e43d 100644 --- a/Lib/test/test_asyncio/test_sslproto.py +++ b/Lib/test/test_asyncio/test_sslproto.py @@ -278,6 +278,7 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin): # No garbage is left if SSL is closed uncleanly client_context = weakref.ref(client_context) + support.gc_collect() self.assertIsNone(client_context()) def test_create_connection_memory_leak(self): @@ -341,6 +342,7 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin): # No garbage is left for SSL client from loop.create_connection, even # if user stores the SSLTransport in corresponding protocol instance client_context = weakref.ref(client_context) + support.gc_collect() self.assertIsNone(client_context()) def test_start_tls_client_buf_proto_1(self): @@ -640,6 +642,7 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin): # The 10s handshake timeout should be cancelled to free related # objects without really waiting for 10s client_sslctx = weakref.ref(client_sslctx) + support.gc_collect() self.assertIsNone(client_sslctx()) def test_create_connection_ssl_slow_handshake(self): diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index a9e4cf5..f7345c5 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -3275,15 +3275,18 @@ class GenericTaskTests(test_utils.TestCase): def test_future_subclass(self): self.assertTrue(issubclass(asyncio.Task, asyncio.Future)) + @support.cpython_only def test_asyncio_module_compiled(self): # Because of circular imports it's easy to make _asyncio # module non-importable. This is a simple test that will # fail on systems where C modules were successfully compiled - # (hence the test for _functools), but _asyncio somehow didn't. + # (hence the test for _functools etc), but _asyncio somehow didn't. try: import _functools + import _json + import _pickle except ImportError: - pass + self.skipTest('C modules are not available') else: try: import _asyncio |