Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug() in IsolatedAsyncioTestCase #89401

Closed
serhiy-storchaka opened this issue Sep 18, 2021 · 6 comments
Closed

Fix debug() in IsolatedAsyncioTestCase #89401

serhiy-storchaka opened this issue Sep 18, 2021 · 6 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 45238
Nosy @rbtcollins, @ezio-melotti, @voidspace, @asvetlov, @ambv, @serhiy-storchaka, @1st1
PRs
  • bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() #28449
  • [3.10] bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() (GH-28449) #28521
  • [3.9] bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() (GH-28449) #28522
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-09-22.16:57:42.192>
    created_at = <Date 2021-09-18.13:54:37.834>
    labels = ['type-bug', '3.9', '3.10', '3.11', 'library', 'expert-asyncio']
    title = 'Fix debug() in IsolatedAsyncioTestCase'
    updated_at = <Date 2021-09-22.16:57:42.191>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2021-09-22.16:57:42.191>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-09-22.16:57:42.192>
    closer = 'lukasz.langa'
    components = ['Library (Lib)', 'asyncio']
    creation = <Date 2021-09-18.13:54:37.834>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45238
    keywords = ['patch']
    message_count = 6.0
    messages = ['402132', '402149', '402446', '402454', '402455', '402456']
    nosy_count = 7.0
    nosy_names = ['rbcollins', 'ezio.melotti', 'michael.foord', 'asvetlov', 'lukasz.langa', 'serhiy.storchaka', 'yselivanov']
    pr_nums = ['28449', '28521', '28522']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45238'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @serhiy-storchaka
    Copy link
    Member Author

    Currently debug() does not work in IsolatedAsyncioTestCase subclasses. It runs synchronous code (setUp(), tearDown(), synchronous tests and cleanup functions), but does not run any asynchronous code (asyncSetUp(), asyncTearDown(), asynchronous tests and cleanup functions) and produces warnings "RuntimeWarning: coroutine 'xxx' was never awaited".

    @serhiy-storchaka serhiy-storchaka added 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error labels Sep 18, 2021
    @serhiy-storchaka
    Copy link
    Member Author

    It turned out be more complicated than I expected. We need to keep the even loop after getting exception in debug() for having ability to run doCleanup() etc. The option is to close the even loop in __del__. But we should ensure that it is closed before running other event loop. Also, assertRaises() creates reference loops, so we cannot use it.

    @ambv
    Copy link
    Contributor

    ambv commented Sep 22, 2021

    New changeset ecb6922 by Serhiy Storchaka in branch 'main':
    bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() (GH-28449)
    ecb6922

    @ambv
    Copy link
    Contributor

    ambv commented Sep 22, 2021

    New changeset 44396aa by Łukasz Langa in branch '3.10':
    [3.10] bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() (GH-28449) (GH-28521)
    44396aa

    @ambv
    Copy link
    Contributor

    ambv commented Sep 22, 2021

    New changeset e06b0fd by Łukasz Langa in branch '3.9':
    [3.9] bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() (GH-28449) (GH-28522)
    e06b0fd

    @ambv
    Copy link
    Contributor

    ambv commented Sep 22, 2021

    Thanks, Serhiy! ✨ 🍰 ✨

    @ambv ambv closed this as completed Sep 22, 2021
    @ambv ambv closed this as completed Sep 22, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants