Skip to content

Strip IsolatedAsyncioTestCase frames from reported stacktraces #90286

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

Closed
asvetlov opened this issue Dec 19, 2021 · 4 comments
Closed

Strip IsolatedAsyncioTestCase frames from reported stacktraces #90286

asvetlov opened this issue Dec 19, 2021 · 4 comments
Labels
3.11 only security fixes 3.12 only security fixes stdlib Python modules in the Lib dir

Comments

@asvetlov
Copy link
Contributor

BPO 46128
Nosy @asvetlov, @serhiy-storchaka
PRs
  • bpo-46128: Strip IsolatedAsyncioTestCase frames from reported stacktraces #30196
  • 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 = None
    created_at = <Date 2021-12-19.08:45:55.760>
    labels = ['library', '3.9', '3.10', '3.11']
    title = 'Strip IsolatedAsyncioTestCase frames from reported stacktraces'
    updated_at = <Date 2021-12-19.11:43:26.633>
    user = 'https://github.com/asvetlov'

    bugs.python.org fields:

    activity = <Date 2021-12-19.11:43:26.633>
    actor = 'asvetlov'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-12-19.08:45:55.760>
    creator = 'asvetlov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46128
    keywords = ['patch']
    message_count = 3.0
    messages = ['408887', '408892', '408895']
    nosy_count = 2.0
    nosy_names = ['asvetlov', 'serhiy.storchaka']
    pr_nums = ['30196']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46128'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @asvetlov
    Copy link
    Contributor Author

    bpo-7815 supports __unittest = True module globals to stripping unittest framework calls from a stacktrace reported by a test failure.

    IsolatedAsyncioTestCase missed this setup.

    @asvetlov asvetlov added 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir labels Dec 19, 2021
    @serhiy-storchaka
    Copy link
    Member

    Thank you. I knew about this issue but forgot to fix it.

    I think it is also needed in _log.py. Not sure about mock.py.

    @asvetlov
    Copy link
    Contributor Author

    __unittest = True flag doesn't work smoothly with async functions, unfortunately.

    Need to investigate why.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @bialix
    Copy link

    bialix commented Mar 2, 2023

    Quite annoying to see internals in traceback. Is it really can't be fixed? Please?

    Just simple example:

    import unittest
    
    class TestAsync(unittest.IsolatedAsyncioTestCase):
        async def test_fail(self):
            self.fail()
    

    And got:

    C:\Temp>python -m unittest
    F
    ======================================================================
    FAIL: test_fail (test_async.TestAsync)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\Python\3.10-64\lib\unittest\async_case.py", line 64, in _callTestMethod
        self._callMaybeAsync(method)
      File "C:\Python\3.10-64\lib\unittest\async_case.py", line 87, in _callMaybeAsync
        return self._asyncioTestLoop.run_until_complete(fut)
      File "C:\Python\3.10-64\lib\asyncio\base_events.py", line 646, in run_until_complete
        return future.result()
      File "C:\Python\3.10-64\lib\unittest\async_case.py", line 101, in _asyncioLoopRunner
        ret = await awaitable
      File "C:\Temp\test_async.py", line 5, in test_fail
        self.fail()
    AssertionError: None
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.013s
    
    FAILED (failures=1)
    

    @hugovk hugovk added 3.12 only security fixes and removed 3.10 only security fixes 3.9 only security fixes labels Apr 7, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes 3.12 only security fixes stdlib Python modules in the Lib dir
    Projects
    Status: Done
    Development

    No branches or pull requests

    5 participants