We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Tests should pass, as they did in 1.2.7.
To run tests, I've added ,pypy3 to PyTest conditions in tox.ini.
,pypy3
tox.ini
The following tests fails with PyPy3:
==================================================================== FAILURES ===================================================================== ___________________________________________________ test_classic_deprecated_class__warns[None] ____________________________________________________ classic_deprecated_class = <class 'tests.test_deprecated.classic_deprecated_class.<locals>.Foo2'> def test_classic_deprecated_class__warns(classic_deprecated_class): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") classic_deprecated_class() assert len(warns) == 1 warn = warns[0] assert issubclass(warn.category, DeprecationWarning) assert "deprecated class" in str(warn.message) > assert warn.filename == __file__, 'Incorrect warning stackLevel' E AssertionError: Incorrect warning stackLevel E assert '/tmp/depreca...est/python.py' == '/tmp/depreca...deprecated.py' E - /tmp/deprecated-1.2.8/tests/test_deprecated.py E + /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py tests/test_deprecated.py:150: AssertionError _________________________________________ test_classic_deprecated_class__warns[classic_deprecated_class1] _________________________________________ classic_deprecated_class = <class 'tests.test_deprecated.classic_deprecated_class.<locals>.Foo2'> def test_classic_deprecated_class__warns(classic_deprecated_class): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") classic_deprecated_class() assert len(warns) == 1 warn = warns[0] assert issubclass(warn.category, DeprecationWarning) assert "deprecated class" in str(warn.message) > assert warn.filename == __file__, 'Incorrect warning stackLevel' E AssertionError: Incorrect warning stackLevel E assert '/tmp/depreca...est/python.py' == '/tmp/depreca...deprecated.py' E - /tmp/deprecated-1.2.8/tests/test_deprecated.py E + /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py tests/test_deprecated.py:150: AssertionError _________________________________________ test_classic_deprecated_class__warns[classic_deprecated_class2] _________________________________________ classic_deprecated_class = <class 'tests.test_deprecated.classic_deprecated_class.<locals>.Foo2'> def test_classic_deprecated_class__warns(classic_deprecated_class): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") classic_deprecated_class() assert len(warns) == 1 warn = warns[0] assert issubclass(warn.category, DeprecationWarning) assert "deprecated class" in str(warn.message) > assert warn.filename == __file__, 'Incorrect warning stackLevel' E AssertionError: Incorrect warning stackLevel E assert '/tmp/depreca...est/python.py' == '/tmp/depreca...deprecated.py' E - /tmp/deprecated-1.2.8/tests/test_deprecated.py E + /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py tests/test_deprecated.py:150: AssertionError _________________________________________ test_classic_deprecated_class__warns[classic_deprecated_class3] _________________________________________ classic_deprecated_class = <class 'tests.test_deprecated.classic_deprecated_class.<locals>.Foo2'> def test_classic_deprecated_class__warns(classic_deprecated_class): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") classic_deprecated_class() assert len(warns) == 1 warn = warns[0] assert issubclass(warn.category, DeprecationWarning) assert "deprecated class" in str(warn.message) > assert warn.filename == __file__, 'Incorrect warning stackLevel' E AssertionError: Incorrect warning stackLevel E assert '/tmp/depreca...est/python.py' == '/tmp/depreca...deprecated.py' E - /tmp/deprecated-1.2.8/tests/test_deprecated.py E + /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py tests/test_deprecated.py:150: AssertionError _________________________________________ test_classic_deprecated_class__warns[classic_deprecated_class4] _________________________________________ classic_deprecated_class = <class 'tests.test_deprecated.classic_deprecated_class.<locals>.Foo2'> def test_classic_deprecated_class__warns(classic_deprecated_class): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") classic_deprecated_class() assert len(warns) == 1 warn = warns[0] assert issubclass(warn.category, DeprecationWarning) assert "deprecated class" in str(warn.message) > assert warn.filename == __file__, 'Incorrect warning stackLevel' E AssertionError: Incorrect warning stackLevel E assert '/tmp/depreca...est/python.py' == '/tmp/depreca...deprecated.py' E - /tmp/deprecated-1.2.8/tests/test_deprecated.py E + /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py tests/test_deprecated.py:150: AssertionError _________________________________________ test_classic_deprecated_class__warns[classic_deprecated_class5] _________________________________________ classic_deprecated_class = <class 'tests.test_deprecated.classic_deprecated_class.<locals>.Foo2'> def test_classic_deprecated_class__warns(classic_deprecated_class): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") classic_deprecated_class() assert len(warns) == 1 warn = warns[0] assert issubclass(warn.category, DeprecationWarning) assert "deprecated class" in str(warn.message) > assert warn.filename == __file__, 'Incorrect warning stackLevel' E AssertionError: Incorrect warning stackLevel E assert '/tmp/depreca...est/python.py' == '/tmp/depreca...deprecated.py' E - /tmp/deprecated-1.2.8/tests/test_deprecated.py E + /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py tests/test_deprecated.py:150: AssertionError _________________________________________ test_classic_deprecated_class__warns[classic_deprecated_class6] _________________________________________ classic_deprecated_class = <class 'tests.test_deprecated.classic_deprecated_class.<locals>.Foo2'> def test_classic_deprecated_class__warns(classic_deprecated_class): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") classic_deprecated_class() assert len(warns) == 1 warn = warns[0] assert issubclass(warn.category, DeprecationWarning) assert "deprecated class" in str(warn.message) > assert warn.filename == __file__, 'Incorrect warning stackLevel' E AssertionError: Incorrect warning stackLevel E assert '/tmp/depreca...est/python.py' == '/tmp/depreca...deprecated.py' E - /tmp/deprecated-1.2.8/tests/test_deprecated.py E + /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py tests/test_deprecated.py:150: AssertionError ================================================================ warnings summary ================================================================= tests/test_deprecated_class.py::test_simple_class_deprecation_with_args /tmp/deprecated-1.2.8/.tox/pypy3/site-packages/_pytest/python.py:184: DeprecationWarning: Call to deprecated class MyClass. (kwargs class) result = testfunction(**testargs) -- Docs: https://docs.pytest.org/en/latest/warnings.html ----------- coverage: platform linux, python 3.6.9-final-0 ----------- Name Stmts Miss Cover Missing ------------------------------------------------------ deprecated/__init__.py 3 0 100% deprecated/classic.py 71 3 96% 22, 130, 280 deprecated/sphinx.py 36 2 94% 124, 150 ------------------------------------------------------ TOTAL 110 5 95% ============================================================= short test summary info ============================================================= FAILED tests/test_deprecated.py::test_classic_deprecated_class__warns[None] - AssertionError: Incorrect warning stackLevel FAILED tests/test_deprecated.py::test_classic_deprecated_class__warns[classic_deprecated_class1] - AssertionError: Incorrect warning stackLevel FAILED tests/test_deprecated.py::test_classic_deprecated_class__warns[classic_deprecated_class2] - AssertionError: Incorrect warning stackLevel FAILED tests/test_deprecated.py::test_classic_deprecated_class__warns[classic_deprecated_class3] - AssertionError: Incorrect warning stackLevel FAILED tests/test_deprecated.py::test_classic_deprecated_class__warns[classic_deprecated_class4] - AssertionError: Incorrect warning stackLevel FAILED tests/test_deprecated.py::test_classic_deprecated_class__warns[classic_deprecated_class5] - AssertionError: Incorrect warning stackLevel FAILED tests/test_deprecated.py::test_classic_deprecated_class__warns[classic_deprecated_class6] - AssertionError: Incorrect warning stackLevel ==================================================== 7 failed, 148 passed, 1 warning in 20.18s ====================================================
I don't know if this isn't a problem with pytest itself and/or pypy3. However,
$ pypy3 --version Python 3.6.9 (1608da62bfc71e8ac775121dd0b21bb72e61c6ea, Dec 25 2019, 15:23:23) [PyPy 7.3.0 with GCC 9.2.0]
The text was updated successfully, but these errors were encountered:
When printing a warning, the message should gives the user the right filename. The filename comes from the current execution stack.
For (still) unknown reason the stacklevel (the position of the caller in the stack) should be 3 if we decorate a function but 2 if it is a class.
Sorry, something went wrong.
Fix #20: Set the :func:warnings.warn stacklevel to 2 if the Python …
warnings.warn
aef92b1
…implementation is `PyPy <https://www.pypy.org/>`_.
Successfully merging a pull request may close this issue.
Expected Behavior
Tests should pass, as they did in 1.2.7.
To run tests, I've added
,pypy3
to PyTest conditions intox.ini
.Actual Behavior
The following tests fails with PyPy3:
I don't know if this isn't a problem with pytest itself and/or pypy3. However,
Environment
The text was updated successfully, but these errors were encountered: