Content-Length: 278841 | pFad | https://github.com/python/cpython/issues/97837

B4 Misleading `DeprecationWarning` in `unittest`: It is deprecated to return a value!=None · Issue #97837 · python/cpython · GitHub
Skip to content

Misleading DeprecationWarning in unittest: It is deprecated to return a value!=None #97837

@sobolevn

Description

@sobolevn

In python != and is not are two different things.
Right now the deprecation warning says !=, let's see if that's true:

from unittest import TestCase, main

class Nothing:
    def __eq__(self, o):
        return o is None

class TestExample(TestCase):
    def test_method(self):
        n = Nothing()
        self.assertEqual(n, None)
        return n

main()

It still raises this:

/Users/sobolev/Desktop/cpython/Lib/unittest/case.py:678: DeprecationWarning: It is deprecated to return a value!=None from a test case (<bound method TestExample.test_method of <__main__.TestExample testMethod=test_method>>)
  return self.run(*args, **kwds)
.
----------------------------------------------------------------------
Ran 1 test in 0.003s

OK

I believe that this is misleading. The proper message should say: It is deprecated to return a value that is not None from a test case

I will send a PR with the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/97837

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy