File: _pytest_plugin.py

package info (click to toggle)
python-cheroot 11.1.2%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,236 kB
  • sloc: python: 6,969; makefile: 10
file content (45 lines) | stat: -rw-r--r-- 1,867 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
"""Local pytest plugin.

Contains hooks, which are tightly bound to the Cheroot framework
itself, useless for end-users' app testing.
"""

import pytest


pytest_version = tuple(map(int, pytest.__version__.split('.')))


def pytest_load_initial_conftests(early_config, parser, args):
    """Drop unfilterable warning ignores."""
    if pytest_version < (6, 2, 0):
        return

    # pytest>=6.2.0 under Python 3.8:
    # Refs:
    # * https://docs.pytest.org/en/stable/usage.html#unraisable
    # * https://github.com/pytest-dev/pytest/issues/5299
    early_config._inicache['filterwarnings'].extend(
        (
            'ignore:Exception in thread CP Server Thread-:'
            'pytest.PytestUnhandledThreadExceptionWarning:_pytest.threadexception',
            'ignore:Exception in thread Thread-:'
            'pytest.PytestUnhandledThreadExceptionWarning:_pytest.threadexception',
            'ignore:Exception ignored in. '
            '<socket.socket fd=-1, family=AddressFamily.AF_INET, '
            'type=SocketKind.SOCK_STREAM, proto=.:'
            'pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception',
            'ignore:Exception ignored in. '
            '<socket.socket fd=-1, family=AddressFamily.AF_INET6, '
            'type=SocketKind.SOCK_STREAM, proto=.:'
            'pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception',
            'ignore:Exception ignored in. '
            '<socket.socket fd=-1, family=AF_INET, '
            'type=SocketKind.SOCK_STREAM, proto=.:'
            'pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception',
            'ignore:Exception ignored in. '
            '<socket.socket fd=-1, family=AF_INET6, '
            'type=SocketKind.SOCK_STREAM, proto=.:'
            'pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception',
        ),
    )