Title: Replace use of `test.test_asyncio.utils.TestCase` with `unittest.IsolatedAsyncioTestCase` · Issue #93357 · python/cpython · GitHub
Open Graph Title: Replace use of `test.test_asyncio.utils.TestCase` with `unittest.IsolatedAsyncioTestCase` · Issue #93357 · python/cpython
X Title: Replace use of `test.test_asyncio.utils.TestCase` with `unittest.IsolatedAsyncioTestCase` · Issue #93357 · python/cpython
Description: Feature or enhancement Get rid of ad-hoc implementation of async tests by using all relatively new features of standard IsolatedAsyncIoTestCase. For this we need to: replace all occurences of class ...(test_utils.TestCase): with class .....
Open Graph Description: Feature or enhancement Get rid of ad-hoc implementation of async tests by using all relatively new features of standard IsolatedAsyncIoTestCase. For this we need to: replace all occurences of class...
X Description: Feature or enhancement Get rid of ad-hoc implementation of async tests by using all relatively new features of standard IsolatedAsyncIoTestCase. For this we need to: replace all occurences of class...
Opengraph URL: https://github.com/python/cpython/issues/93357
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Replace use of `test.test_asyncio.utils.TestCase` with `unittest.IsolatedAsyncioTestCase`","articleBody":"**Feature or enhancement**\r\n\r\nGet rid of ad-hoc implementation of async tests by using all relatively new features of standard `IsolatedAsyncIoTestCase`. For this we need to:\r\n\r\n- replace all occurences of `class ...(test_utils.TestCase):` with `class ...(unittest.IsolatedAsynIoTestCase):`\r\n- remove manually created event loops in favor of the builtin one of `IsolatedAsyncIoTestCase`\r\n- make loop-dependend test cases `async`\r\n- replace multithreading with `asyncio` wherever possible\r\n- remove unused imports\r\n- remove the `TestCase` and classes it uses ([588 -\u003e 346 lines in test_asyncio/utils.py](https://github.com/python/cpython/compare/main...arhadthedev:remove-utilstestcase?expand=1))\r\n\r\n**Pitch**\r\n\r\n- `test_asyncio.utils.TestCase` provides no extra functionality over `IsolatedAsyncioTestCase`. Instead, it takes 200+ lines of code together with two more classes used nowhere else (`TestSelector` and `TestLoop`)\r\n- `TestCase` requires manual scheduling of tasks using `loop.run_until_complete` while `IsolatedAsyncioTestCase` allows `await`\r\n- `TestCase` was introduced on 2014 by c73701de7292b7de0fee5b7f82a610d7515c18a4 while `IsolatedAsynIoTestCase` was introduced 5 years later by 4dd3e3f9bbd320f0dd556688e04db0a6b55a7b52\r\n\r\n**Progress tracking**\r\n\r\n- [ ] find and fix a bug described in https://github.com/python/cpython/pull/98015#issuecomment-1271136419\r\n- [ ] test/test_asyncgen.py\r\n- [ ] test/test_coroutines.py\r\n- [ ] test/test_pdb.py\r\n- [ ] test/test_asyncio/test_base_events.py\r\n- [ ] test/test_asyncio/test_events.py\r\n- [ ] test/test_asyncio/test_futures.py\r\n- [ ] test/test_asyncio/test_pep492.py\r\n- [ ] test/test_asyncio/test_proactor_events.py\r\n- [ ] test/test_asyncio/test_sendfile.py\r\n- [ ] test/test_asyncio/test_sock_lowlevel.py\r\n- [ ] test/test_asyncio/test_ssl.py\r\n- [ ] test/test_asyncio/test_sslproto.py\r\n- [ ] test/test_asyncio/test_streams.py\r\n - gh-93369\r\n - gh-97896\r\n - gh-98015\r\n- [ ] test/test_asyncio/test_subprocess.py\r\n- [ ] test/test_asyncio/test_tasks.py\r\n- [ ] test/test_asyncio/test_unix_events.py\r\n- [ ] test/test_asyncio/test_windows_events.py\r\n- [ ] replace multithreading with asyncio wherever possible\r\n- [ ] remove the `TestCase`\r\n- [ ] move `asyncio.set_event_loop_policy(None)` (a measure agains \"test altered the execution environment\" warning) into `IsolatedAsyncioTestCase`'s shutdown method\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eThere are 83 cases that use test_asyncio.utils.TestCase\u003c/summary\u003e\r\n\r\n- `test/test_asyncio/test_base_events.py:class BaseEventTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_base_events.py:class BaseEventLoopTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_base_events.py:class BaseEventLoopWithSelectorTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_base_events.py:class BaseLoopSockSendfileTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_base_events.py:class TestSelectorUtils(test_utils.TestCase):`\r\n- `test/test_asyncio/test_events.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_events.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_events.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_events.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_events.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_events.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_events.py:class HandleTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py:class DuckTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py:class CFutureTests(BaseFutureTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py:class CSubFutureTests(BaseFutureTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py:class PyFutureTests(BaseFutureTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_futures.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_pep492.py:class BaseTest(test_utils.TestCase):`\r\n- `test/test_asyncio/test_proactor_events.py:class ProactorSocketTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_proactor_events.py:class ProactorDatagramTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_proactor_events.py:class BaseProactorEventLoopTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_proactor_events.py:class ProactorEventLoopUnixSockSendfileTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_selector_events.py:class BaseSelectorEventLoopTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_selector_events.py:class SelectorTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_selector_events.py:class SelectorSocketTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_selector_events.py:class SelectorSocketTransportBufferedProtocolTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_selector_events.py:class SelectorDatagramTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_sendfile.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sendfile.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sendfile.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sendfile.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sendfile.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sendfile.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sock_lowlevel.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sock_lowlevel.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sock_lowlevel.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sock_lowlevel.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sock_lowlevel.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_sock_lowlevel.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_ssl.py:class TestSSL(test_utils.TestCase):`\r\n- `test/test_asyncio/test_sslproto.py:class SslProtoHandshakeTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_streams.py:class StreamTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_subprocess.py:class SubprocessTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_subprocess.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_subprocess.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_subprocess.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_subprocess.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_subprocess.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_subprocess.py: class SubprocessProactorTests(SubprocessMixin, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class CTask_CFuture_SubclassTests(BaseTaskTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class CTaskSubclass_PyFuture_Tests(BaseTaskTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class PyTask_CFutureSubclass_Tests(BaseTaskTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class CTask_PyFuture_Tests(BaseTaskTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class PyTask_CFuture_Tests(BaseTaskTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py: test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class PyTask_PyFuture_SubclassTests(BaseTaskTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class CTask_Future_Tests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class PyIntrospectionTests(test_utils.TestCase, BaseTaskIntrospectionTests):`\r\n- `test/test_asyncio/test_tasks.py:class CIntrospectionTests(test_utils.TestCase, BaseTaskIntrospectionTests):`\r\n- `test/test_asyncio/test_tasks.py:class PyCurrentLoopTests(BaseCurrentLoopTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class CCurrentLoopTests(BaseCurrentLoopTests, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class GenericTaskTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class FutureGatherTests(GatherTestsBase, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class CoroutineGatherTests(GatherTestsBase, test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class RunCoroutineThreadsafeTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class SleepTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_tasks.py:class CompatibilityTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_unix_events.py:class SelectorEventLoopSignalTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_unix_events.py:class SelectorEventLoopUnixSocketTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_unix_events.py:class SelectorEventLoopUnixSockSendfileTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_unix_events.py:class UnixReadPipeTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_unix_events.py:class UnixWritePipeTransportTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_unix_events.py:class SafeChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):`\r\n- `test/test_asyncio/test_unix_events.py:class FastChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):`\r\n- `test/test_asyncio/test_windows_events.py:class ProactorLoopCtrlC(test_utils.TestCase):`\r\n- `test/test_asyncio/test_windows_events.py:class ProactorMultithreading(test_utils.TestCase):`\r\n- `test/test_asyncio/test_windows_events.py:class ProactorTests(test_utils.TestCase):`\r\n- `test/test_asyncio/test_windows_events.py:class WinPolicyTests(test_utils.TestCase):`\r\n\u003c/details\u003e\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-98877\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/arhadthedev","@type":"Person","name":"arhadthedev"},"datePublished":"2022-05-30T16:35:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/93357/cpython/issues/93357"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a699a590-7c39-f8b4-7fef-ea67687ba4e6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A0B0:24B4E0:98D05F:CD009E:6969C1C3 |
| html-safe-nonce | c55c8e7f4adcbdede99236b46da17290035b2c3ab1b0b1b8942774f1f23a429a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEIwOjI0QjRFMDo5OEQwNUY6Q0QwMDlFOjY5NjlDMUMzIiwidmlzaXRvcl9pZCI6IjI4MjY0OTIwNTQ4NDM1Mzk5MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6cf9b93aa2017822153085fac5a3dad8f888e1ea3dcf4fdc3a3db221d2901b62 |
| hovercard-subject-tag | issue:1252948649 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/93357/issue_layout |
| twitter:image | https://opengraph.githubassets.com/95c89f087286c23353be3e9bf817f7a52bd60955a8674105f7a666827945b313/python/cpython/issues/93357 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/95c89f087286c23353be3e9bf817f7a52bd60955a8674105f7a666827945b313/python/cpython/issues/93357 |
| og:image:alt | Feature or enhancement Get rid of ad-hoc implementation of async tests by using all relatively new features of standard IsolatedAsyncIoTestCase. For this we need to: replace all occurences of class... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | arhadthedev |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width