Skip to content

Improve deprecation warning message, when a test case returns non None value #120388

Closed

Description

@sobolevn

Feature or enhancement

Right now there are two potential things we can improve in this warning message:

def _callTestMethod(self, method):
if method() is not None:
warnings.warn(f'It is deprecated to return a value that is not None from a '
f'test case ({method})', DeprecationWarning, stacklevel=3)

  1. The returned value's type is not shown. It can be useful for users
  2. A common case for this warning is that async def test_some is defined in a regular TestCase class, I think that we can improve this specific case and suggest to use IsolatedAsyncioTestCase instead

I have a patch ready.

Linked PRs

Activity

  1. added
    type-featureA feature request or enhancement
    testsTests in the Lib/test dir
    on Jun 12, 2024
  2. self-assigned this
    on Jun 12, 2024
  3. added 4 commits that reference this issue on Jun 12, 2024
  4. AlexWaygood commented on Jun 12, 2024

    @AlexWaygood
    Member

    Thanks for doing this @sobolevn! :D

  5. added a commit that references this issue on Jun 30, 2024
  6. added a commit that references this issue on Jul 11, 2024
  7. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions