File: test_utils.py

package info (click to toggle)
python-cyclopts 3.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,288 kB
  • sloc: python: 11,445; makefile: 24
file content (20 lines) | stat: -rw-r--r-- 525 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
import pytest

from cyclopts.utils import Sentinel, grouper


def test_grouper():
    assert [(1,), (2,), (3,), (4,)] == list(grouper([1, 2, 3, 4], 1))
    assert [(1, 2), (3, 4)] == list(grouper([1, 2, 3, 4], 2))
    assert [(1, 2, 3, 4)] == list(grouper([1, 2, 3, 4], 4))

    with pytest.raises(ValueError):
        grouper([1, 2, 3, 4], 3)


def test_sentinel():
    class SENTINEL_VALUE(Sentinel):  # noqa: N801
        pass

    assert str(SENTINEL_VALUE) == "<SENTINEL_VALUE>"
    assert bool(SENTINEL_VALUE) is False