Skip to content

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

Closed
@alex

Description

@alex

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions