File: test_util.py

package info (click to toggle)
python-openapi-core 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,008 kB
  • sloc: python: 18,868; makefile: 47
file content (22 lines) | stat: -rw-r--r-- 611 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
import pytest

from openapi_core.util import forcebool


class TestForcebool:
    @pytest.mark.parametrize("val", ["y", "yes", "t", "true", "on", "1", True])
    def test_true(self, val):
        result = forcebool(val)
        assert result is True

    @pytest.mark.parametrize(
        "val", ["n", "no", "f", "false", "off", "0", False]
    )
    def test_false(self, val):
        result = forcebool(val)
        assert result is False

    @pytest.mark.parametrize("val", ["random", "idontknow", ""])
    def test_value_error(self, val):
        with pytest.raises(ValueError):
            forcebool(val)