Title: `self.doCleanups()` cannot be called from a test method of a `unittest.IsolatedAsyncioTestCase` subclass · Issue #101018 · python/cpython · GitHub
Open Graph Title: `self.doCleanups()` cannot be called from a test method of a `unittest.IsolatedAsyncioTestCase` subclass · Issue #101018 · python/cpython
X Title: `self.doCleanups()` cannot be called from a test method of a `unittest.IsolatedAsyncioTestCase` subclass · Issue #101018 · python/cpython
Description: Example: import unittest events = [] class Test(unittest.IsolatedAsyncioTestCase): def test(self): events.append('started') self.addCleanup(events.append, 'cleanup') self.doCleanups() events.append('end') unittest.main(exit=False) assert...
Open Graph Description: Example: import unittest events = [] class Test(unittest.IsolatedAsyncioTestCase): def test(self): events.append('started') self.addCleanup(events.append, 'cleanup') self.doCleanups() events.append...
X Description: Example: import unittest events = [] class Test(unittest.IsolatedAsyncioTestCase): def test(self): events.append('started') self.addCleanup(events.append, 'cleanup') self.doCleanups...
Opengraph URL: https://github.com/python/cpython/issues/101018
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`self.doCleanups()` cannot be called from a test method of a `unittest.IsolatedAsyncioTestCase` subclass","articleBody":"Example:\r\n\r\n```python\r\nimport unittest\r\n\r\n\r\nevents = []\r\n\r\nclass Test(unittest.IsolatedAsyncioTestCase):\r\n\r\n def test(self):\r\n events.append('started')\r\n self.addCleanup(events.append, 'cleanup')\r\n self.doCleanups()\r\n events.append('end')\r\n\r\nunittest.main(exit=False)\r\n\r\nassert events == ['started', 'cleanup', 'end'], events\r\n```\r\n\r\nThe above passes in 3.9 and 3.10, but fails in 3.11 with\r\n\r\n```\r\nE\r\n======================================================================\r\nERROR: test (__main__.Test)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n File \"/.../cpython/Lib/unittest/async_case.py\", line 75, in _callCleanup\r\n self._callMaybeAsync(function, *args, **kwargs)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/.../cpython/Lib/unittest/async_case.py\", line 95, in _callMaybeAsync\r\n return self._asyncioTestContext.run(func, *args, **kwargs)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nRuntimeError: cannot enter context: \u003c_contextvars.Context object at 0x7fb2f93a9900\u003e is already entered\r\n\r\n----------------------------------------------------------------------\r\nRan 1 test in 0.002s\r\n\r\nFAILED (errors=1)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 16, in \u003cmodule\u003e\r\nAssertionError: ['started', 'end']\r\n```\r\n\r\n`git bisect` found the culprit to be gh-91150/GH-31837.","author":{"url":"https://github.com/zware","@type":"Person","name":"zware"},"datePublished":"2023-01-13T18:57:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/101018/cpython/issues/101018"}
| 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:bc953c8d-bbf4-3b3a-961f-e7a391b9388d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DDFC:70BC8:CF077:122B75:696A6873 |
| html-safe-nonce | a500eaef6bf3eb28a91847ebe85c6e5542b8c4b5421896e0d973783e4605d48a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREZDOjcwQkM4OkNGMDc3OjEyMkI3NTo2OTZBNjg3MyIsInZpc2l0b3JfaWQiOiIzNzA3NDEzMDA1NzE2ODQyNjExIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8489b734967908063447c4ce240207791ddbbf3017284e9d4b509cfc5fa835ea |
| hovercard-subject-tag | issue:1532765686 |
| 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/101018/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f69bcfc68ddf033bde08610e055c080765a97ab1694f83f99541a3ac0ab7e7be/python/cpython/issues/101018 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f69bcfc68ddf033bde08610e055c080765a97ab1694f83f99541a3ac0ab7e7be/python/cpython/issues/101018 |
| og:image:alt | Example: import unittest events = [] class Test(unittest.IsolatedAsyncioTestCase): def test(self): events.append('started') self.addCleanup(events.append, 'cleanup') self.doCleanups() events.append... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zware |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6fea32d5b7276b841b7a803796d9715bc6cfb31ed549fdf9de2948ac25d12ba6 |
| 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 | f2d9f6432a5a115ec709295ae70623f33bb80aee |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width