Skip to content

pytest.warn doesn't appear to be working for deprecation warnings #1026

@alex

Description

@alex

I'm not sure what to make of this, but it appears to be failing on a very simple test:

(tempenv-6cb925871591c) ~/.v/tempenv-6cb925871591c $ cat t.py
import warnings

import pytest


def test_foo():
    with pytest.warns(PendingDeprecationWarning):
        warnings.warn("msg", PendingDeprecationWarning)
(tempenv-6cb925871591c) ~/.v/tempenv-6cb925871591c $ py.test t.py
====================================================== test session starts =======================================================
platform darwin -- Python 2.7.10, pytest-2.8.0, py-1.4.30, pluggy-0.3.1
rootdir: /Users/alex_gaynor/.virtualenvs/tempenv-6cb925871591c, inifile:
collected 1 items

t.py F

============================================================ FAILURES ============================================================
____________________________________________________________ test_foo ____________________________________________________________

    def test_foo():
        with pytest.warns(PendingDeprecationWarning):
>           warnings.warn("msg", PendingDeprecationWarning)
E           Failed: DID NOT WARN

t.py:8: Failed
==================================================== 1 failed in 0.01 seconds ====================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topictype: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions