File: test_str_function.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 (33 lines) | stat: -rw-r--r-- 910 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
"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""

import itertools

import pytest

from typepy import is_not_null_string, is_null_string


nan = float("nan")
inf = float("inf")


class Test_is_not_null_string:
    @pytest.mark.parametrize(
        ["value", "expected"],
        list(itertools.product(["nan", "テスト"], [True]))
        + list(itertools.product([None, "", "  ", "\t", "\r\n", "\n", [], 1, True, nan], [False])),
    )
    def test_normal(self, value, expected):
        assert is_not_null_string(value) == expected


class Test_is_null_string:
    @pytest.mark.parametrize(
        ["value", "expected"],
        list(itertools.product([None, "", "  ", "\t", "\r\n", "\n"], [True]))
        + list(itertools.product(["nan", "テスト", [], 1, True, nan], [False])),
    )
    def test_normal(self, value, expected):
        assert is_null_string(value) == expected