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

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

Closed
sobolevn opened this issue Jun 12, 2024 · 1 comment
Closed
Assignees
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@sobolevn
Copy link
Member

sobolevn commented Jun 12, 2024

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

@sobolevn sobolevn added type-feature A feature request or enhancement tests Tests in the Lib/test dir labels Jun 12, 2024
@sobolevn sobolevn self-assigned this Jun 12, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Jun 12, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Jun 12, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Jun 12, 2024
sobolevn added a commit that referenced this issue Jun 12, 2024
…-None (#120401)

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@AlexWaygood
Copy link
Member

Thanks for doing this @sobolevn! :D

mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
…ns non-None (python#120401)

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…ns non-None (python#120401)

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…ns non-None (python#120401)

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants