Skip to content

pytest.deprecated_call() prints on stdout with -s #2341

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

Closed
alex opened this issue Apr 1, 2017 · 1 comment
Closed

pytest.deprecated_call() prints on stdout with -s #2341

alex opened this issue Apr 1, 2017 · 1 comment
Labels
type: bug problem that needs to be addressed

Comments

@alex
Copy link
Contributor

alex commented Apr 1, 2017

Simple test case:

import warnings

import pytest


def test_foo():
    with pytest.deprecated_call():
        warnings.warn("message", DeprecationWarning)

When run with -s, the warning is printed to stdout:

(tempenv-0c76308967598) ~/.v/tempenv-0c76308967598 ❯❯❯ py.test -s test.py
====================================================== test session starts =======================================================
platform darwin -- Python 2.7.13, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /Users/alex_gaynor/.virtualenvs/tempenv-0c76308967598, inifile:
collected 1 items

test.py /Users/alex_gaynor/.virtualenvs/tempenv-0c76308967598/test.py:8: DeprecationWarning: message
  warnings.warn("message", DeprecationWarning)
.

==================================================== 1 passed in 0.00 seconds ====================================================

My expectation is that the output would be captured internally, and not need to be printed.

Package versions:

(tempenv-0c76308967598) ~/.v/tempenv-0c76308967598 ❯❯❯ pip list
Package    Version
---------- -------
appdirs    1.4.3
packaging  16.8
pip        9.0.1
py         1.4.33
pyparsing  2.2.0
pytest     3.0.7
setuptools 34.3.3
six        1.10.0
wheel      0.29.0
@RonnyPfannschmidt RonnyPfannschmidt added the type: bug problem that needs to be addressed label May 13, 2017
@RonnyPfannschmidt
Copy link
Member

@alex according to the history we fixed it in 22864b7 which will be in 3.1 as it got merged as part of #2303

the problem is that our custom code did unconditional calling to the original function, the stdlib one behaves correct from the get go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

2 participants