File: test_bool.py

package info (click to toggle)
python-typepy 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 624 kB
  • sloc: python: 2,886; makefile: 78; sh: 7
file content (74 lines) | stat: -rw-r--r-- 2,806 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""

import pytest

import typepy

from ._common import convert_wrapper


class Test_Bool:
    @pytest.mark.parametrize(
        ["method", "strict_level", "value", "expected"],
        [
            ["convert", 0, True, True],
            ["convert", 0, False, False],
            ["convert", 0, "true", True],
            ["convert", 0, "FALSE", False],
            ["convert", 0, 1, True],
            ["convert", 0, 1.1, "E"],
            ["convert", 0, None, "E"],
            ["convert", 1, True, True],
            ["convert", 1, "true", True],
            ["convert", 1, "FALSE", False],
            ["convert", 1, 1, "E"],
            ["convert", 1, 1.1, "E"],
            ["convert", 1, None, "E"],
            ["convert", 2, True, True],
            ["convert", 2, "true", "E"],
            ["convert", 2, "FALSE", "E"],
            ["convert", 2, 1, "E"],
            ["convert", 2, 1.1, "E"],
            ["convert", 2, None, "E"],
            ["try_convert", 0, True, True],
            ["try_convert", 0, "true", True],
            ["try_convert", 0, "FALSE", False],
            ["try_convert", 0, 1, True],
            ["try_convert", 0, 1.1, None],
            ["try_convert", 0, None, None],
            ["try_convert", 1, True, True],
            ["try_convert", 1, "true", True],
            ["try_convert", 1, "FALSE", False],
            ["try_convert", 1, 1, None],
            ["try_convert", 1, 1.1, None],
            ["try_convert", 1, None, None],
            ["try_convert", 2, True, True],
            ["try_convert", 2, "true", None],
            ["try_convert", 2, "FALSE", None],
            ["try_convert", 2, 1, None],
            ["try_convert", 2, 1.1, None],
            ["try_convert", 2, None, None],
            ["force_convert", 0, True, True],
            ["force_convert", 0, "true", True],
            ["force_convert", 0, "FALSE", False],
            ["force_convert", 0, 1, True],
            ["force_convert", 0, 1.1, "E"],
            ["force_convert", 0, None, "E"],
            ["force_convert", 1, True, True],
            ["force_convert", 1, "true", True],
            ["force_convert", 1, "FALSE", False],
            ["force_convert", 1, 1, True],
            ["force_convert", 1, 1.1, "E"],
            ["force_convert", 1, None, "E"],
            ["force_convert", 2, True, True],
            ["force_convert", 2, "true", True],
            ["force_convert", 2, "FALSE", False],
            ["force_convert", 2, 1, True],
            ["force_convert", 2, 1.1, "E"],
            ["force_convert", 2, None, "E"],
        ],
    )
    def test_normal(self, method, strict_level, value, expected):
        assert convert_wrapper(typepy.Bool(value, strict_level), method) == expected