summaryrefslogtreecommitdiff
path: root/tests/conftest.py
blob: e98025174449e2c6196fa76c88c5a5ffec721ea9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt

"""
Pytest auto configuration.

This module is run automatically by pytest, to define and enable fixtures.
"""

import warnings

import pytest

from coverage import env


@pytest.fixture(autouse=True)
def set_warnings():
    """Enable DeprecationWarnings during all tests."""
    warnings.simplefilter("default")
    warnings.simplefilter("once", DeprecationWarning)

    # A warning to suppress:
    #   setuptools/py33compat.py:54: DeprecationWarning: The value of convert_charrefs will become
    #   True in 3.5. You are encouraged to set the value explicitly.
    #       unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
    warnings.filterwarnings(
        "ignore",
        category=DeprecationWarning,
        message="The value of convert_charrefs will become True in 3.5.",
        )
    if env.PYPY and env.PY3:
        # pypy3 warns about unclosed files a lot.
        # pylint: disable=undefined-variable
        warnings.filterwarnings("ignore", r".*unclosed file", category=ResourceWarning)