File: test_errors.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 (43 lines) | stat: -rw-r--r-- 1,041 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
"""Test suite for ``cheroot.errors``."""

import pytest

from cheroot import errors

from .._compat import (  # noqa: WPS130
    IS_LINUX,
    IS_MACOS,
    IS_SOLARIS,
    IS_WINDOWS,
)


@pytest.mark.parametrize(
    ('err_names', 'err_nums'),
    (
        (('', 'some-nonsense-name'), []),
        (
            (
                'EPROTOTYPE',
                'EAGAIN',
                'EWOULDBLOCK',
                'WSAEWOULDBLOCK',
                'EPIPE',
            ),
            (91, 11, 32)
            if IS_LINUX
            else (32, 35, 41)
            if IS_MACOS
            else (98, 11, 32)
            if IS_SOLARIS
            else (32, 10041, 11, 10035)
            if IS_WINDOWS
            else (),
        ),
    ),
)
def test_plat_specific_errors(err_names, err_nums):
    """Test that ``plat_specific_errors`` gets correct error numbers list."""
    actual_err_nums = errors.plat_specific_errors(*err_names)
    assert len(actual_err_nums) == len(err_nums)
    assert sorted(actual_err_nums) == sorted(err_nums)