laurent-laporte-pro / deprecated

Python @deprecated decorator to deprecate old python classes, functions or methods.
MIT License
307 stars 34 forks source link

Tests fail on py3.9 #29

Closed mgorny closed 4 years ago

mgorny commented 4 years ago

Expected Behavior

Tests should pass ;-).

Actual Behavior

This is most likely due to Python 3.9 fixing @classmethod behavior (see also: GrahamDumpleton/wrapt#160). Now the deprecation is correctly reported as 'class method' rather than 'deprecated function (or staticmethod)'.

GLOB sdist-make: /tmp/deprecated/setup.py
py39 inst-nodeps: /tmp/deprecated/.tox/.tmp/package/1/Deprecated-1.2.11.zip
py39 installed: attrs==19.3.0,coverage==4.5.4,Deprecated @ file:///tmp/deprecated/.tox/.tmp/package/1/Deprecated-1.2.11.zip,more-itertools==8.3.0,packaging==20.4,pluggy==0.13.1,py==1.8.1,pyparsing==2.4.7,pytest==5.4.2,pytest-cov==2.9.0,six==1.15.0,wcwidth==0.1.9,wrapt==1.12.1
py39 run-test-pre: PYTHONHASHSEED='2163554996'
py39 run-test: commands[0] | pytest --cov-report term-missing --cov=deprecated tests/
============================= test session starts ==============================
platform linux -- Python 3.9.0b1, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
cachedir: .tox/py39/.pytest_cache
rootdir: /tmp/deprecated, inifile: setup.cfg
plugins: cov-2.9.0
collected 156 items

tests/test.py ..                                                         [  1%]
tests/test_deprecated.py ............................FFFFFFF......       [ 27%]
tests/test_deprecated_class.py .......                                   [ 32%]
tests/test_deprecated_metaclass.py ....                                  [ 34%]
tests/test_sphinx.py ................................................... [ 67%]
...............................FFFFFFF......                             [ 95%]
tests/test_sphinx_class.py ...                                           [ 97%]
tests/test_sphinx_metaclass.py ....                                      [100%]

=================================== FAILURES ===================================
______________ test_classic_deprecated_class_method__warns[None] _______________

classic_deprecated_class_method = <class 'tests.test_deprecated.classic_deprecated_class_method.<locals>.Foo5'>

    def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = classic_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(DeprecationWarning('Call to deprecated class method foo5.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f2804045a00>.message

tests/test_deprecated.py:187: AssertionError
_ test_classic_deprecated_class_method__warns[classic_deprecated_class_method1] _

classic_deprecated_class_method = <class 'tests.test_deprecated.classic_deprecated_class_method.<locals>.Foo5'>

    def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = classic_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(DeprecationWarning('Call to deprecated class method foo5.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f2804062b50>.message

tests/test_deprecated.py:187: AssertionError
_ test_classic_deprecated_class_method__warns[classic_deprecated_class_method2] _

classic_deprecated_class_method = <class 'tests.test_deprecated.classic_deprecated_class_method.<locals>.Foo5'>

    def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = classic_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5. (Good reason)'
E        +  where 'Call to deprecated class method foo5. (Good reason)' = str(DeprecationWarning('Call to deprecated class method foo5. (Good reason)'))
E        +    where DeprecationWarning('Call to deprecated class method foo5. (Good reason)') = <warnings.WarningMessage object at 0x7f2804071190>.message

tests/test_deprecated.py:187: AssertionError
_ test_classic_deprecated_class_method__warns[classic_deprecated_class_method3] _

classic_deprecated_class_method = <class 'tests.test_deprecated.classic_deprecated_class_method.<locals>.Foo5'>

    def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = classic_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5. (Good reason)'
E        +  where 'Call to deprecated class method foo5. (Good reason)' = str(DeprecationWarning('Call to deprecated class method foo5. (Good reason)'))
E        +    where DeprecationWarning('Call to deprecated class method foo5. (Good reason)') = <warnings.WarningMessage object at 0x7f28040625b0>.message

tests/test_deprecated.py:187: AssertionError
_ test_classic_deprecated_class_method__warns[classic_deprecated_class_method4] _

classic_deprecated_class_method = <class 'tests.test_deprecated.classic_deprecated_class_method.<locals>.Foo5'>

    def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = classic_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5. -- Deprecated since version 1.2.3.'
E        +  where 'Call to deprecated class method foo5. -- Deprecated since version 1.2.3.' = str(DeprecationWarning('Call to deprecated class method foo5. -- Deprecated since version 1.2.3.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5. -- Deprecated since version 1.2.3.') = <warnings.WarningMessage object at 0x7f2804071a30>.message

tests/test_deprecated.py:187: AssertionError
_ test_classic_deprecated_class_method__warns[classic_deprecated_class_method5] _

classic_deprecated_class_method = <class 'tests.test_deprecated.classic_deprecated_class_method.<locals>.Foo5'>

    def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = classic_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(DeprecationWarning('Call to deprecated class method foo5.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f28040452b0>.message

tests/test_deprecated.py:187: AssertionError
_ test_classic_deprecated_class_method__warns[classic_deprecated_class_method6] _

classic_deprecated_class_method = <class 'tests.test_deprecated.classic_deprecated_class_method.<locals>.Foo5'>

    def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = classic_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(MyDeprecationWarning('Call to deprecated class method foo5.'))
E        +    where MyDeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f280405c2e0>.message

tests/test_deprecated.py:187: AssertionError
_______________ test_sphinx_deprecated_class_method__warns[None] _______________

sphinx_deprecated_class_method = <class 'tests.test_sphinx.sphinx_deprecated_class_method.<locals>.Foo5'>

    def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = sphinx_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(DeprecationWarning('Call to deprecated class method foo5.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f2803fcb310>.message

tests/test_sphinx.py:337: AssertionError
_ test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method1] __

sphinx_deprecated_class_method = <class 'tests.test_sphinx.sphinx_deprecated_class_method.<locals>.Foo5'>

    def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = sphinx_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(DeprecationWarning('Call to deprecated class method foo5.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f2803fe6f10>.message

tests/test_sphinx.py:337: AssertionError
_ test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method2] __

sphinx_deprecated_class_method = <class 'tests.test_sphinx.sphinx_deprecated_class_method.<locals>.Foo5'>

    def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = sphinx_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5. (Good reason)'
E        +  where 'Call to deprecated class method foo5. (Good reason)' = str(DeprecationWarning('Call to deprecated class method foo5. (Good reason)'))
E        +    where DeprecationWarning('Call to deprecated class method foo5. (Good reason)') = <warnings.WarningMessage object at 0x7f2803ff10d0>.message

tests/test_sphinx.py:337: AssertionError
_ test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method3] __

sphinx_deprecated_class_method = <class 'tests.test_sphinx.sphinx_deprecated_class_method.<locals>.Foo5'>

    def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = sphinx_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5. (Good reason)'
E        +  where 'Call to deprecated class method foo5. (Good reason)' = str(DeprecationWarning('Call to deprecated class method foo5. (Good reason)'))
E        +    where DeprecationWarning('Call to deprecated class method foo5. (Good reason)') = <warnings.WarningMessage object at 0x7f2803fe1790>.message

tests/test_sphinx.py:337: AssertionError
_ test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method4] __

sphinx_deprecated_class_method = <class 'tests.test_sphinx.sphinx_deprecated_class_method.<locals>.Foo5'>

    def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = sphinx_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5. -- Deprecated since version 1.2.3.'
E        +  where 'Call to deprecated class method foo5. -- Deprecated since version 1.2.3.' = str(DeprecationWarning('Call to deprecated class method foo5. -- Deprecated since version 1.2.3.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5. -- Deprecated since version 1.2.3.') = <warnings.WarningMessage object at 0x7f28040bdac0>.message

tests/test_sphinx.py:337: AssertionError
_ test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method5] __

sphinx_deprecated_class_method = <class 'tests.test_sphinx.sphinx_deprecated_class_method.<locals>.Foo5'>

    def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = sphinx_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(DeprecationWarning('Call to deprecated class method foo5.'))
E        +    where DeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f2803fead60>.message

tests/test_sphinx.py:337: AssertionError
_ test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method6] __

sphinx_deprecated_class_method = <class 'tests.test_sphinx.sphinx_deprecated_class_method.<locals>.Foo5'>

    def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter("always")
            cls = sphinx_deprecated_class_method()
            cls.foo5()
        assert len(warns) == 1
        warn = warns[0]
        assert issubclass(warn.category, DeprecationWarning)
>       assert "deprecated function (or staticmethod)" in str(warn.message)
E       AssertionError: assert 'deprecated function (or staticmethod)' in 'Call to deprecated class method foo5.'
E        +  where 'Call to deprecated class method foo5.' = str(MyDeprecationWarning('Call to deprecated class method foo5.'))
E        +    where MyDeprecationWarning('Call to deprecated class method foo5.') = <warnings.WarningMessage object at 0x7f280405cac0>.message

tests/test_sphinx.py:337: AssertionError
=============================== warnings summary ===============================
tests/test_deprecated_class.py::test_simple_class_deprecation_with_args
  /tmp/deprecated/tests/test_deprecated_class.py:148: DeprecationWarning: Call to deprecated class MyClass. (kwargs class)
    MyClass(5)

-- Docs: https://docs.pytest.org/en/latest/warnings.html

----------- coverage: platform linux, python 3.9.0-beta-1 ------------
Name                     Stmts   Miss  Cover   Missing
------------------------------------------------------
deprecated/__init__.py       3      0   100%
deprecated/classic.py       79      6    92%   25-30, 290
deprecated/sphinx.py        38      2    95%   124, 150
------------------------------------------------------
TOTAL                      120      8    93%

=========================== short test summary info ============================
FAILED tests/test_deprecated.py::test_classic_deprecated_class_method__warns[None]
FAILED tests/test_deprecated.py::test_classic_deprecated_class_method__warns[classic_deprecated_class_method1]
FAILED tests/test_deprecated.py::test_classic_deprecated_class_method__warns[classic_deprecated_class_method2]
FAILED tests/test_deprecated.py::test_classic_deprecated_class_method__warns[classic_deprecated_class_method3]
FAILED tests/test_deprecated.py::test_classic_deprecated_class_method__warns[classic_deprecated_class_method4]
FAILED tests/test_deprecated.py::test_classic_deprecated_class_method__warns[classic_deprecated_class_method5]
FAILED tests/test_deprecated.py::test_classic_deprecated_class_method__warns[classic_deprecated_class_method6]
FAILED tests/test_sphinx.py::test_sphinx_deprecated_class_method__warns[None]
FAILED tests/test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method1]
FAILED tests/test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method2]
FAILED tests/test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method3]
FAILED tests/test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method4]
FAILED tests/test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method5]
FAILED tests/test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method6]
================== 14 failed, 142 passed, 1 warning in 0.52s ===================
ERROR: InvocationError for command /tmp/deprecated/.tox/py39/bin/pytest --cov-report term-missing --cov=deprecated tests/ (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py39: commands failed

Environment