File: test_sequence.py

package info (click to toggle)
litestar 2.19.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,500 kB
  • sloc: python: 70,169; makefile: 254; javascript: 105; sh: 60
file content (21 lines) | stat: -rw-r--r-- 528 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
from litestar.utils.sequence import find_index, unique


def test_find_index() -> None:
    assert find_index([1, 2], lambda x: x == 2) == 1
    assert find_index([1, 3], lambda x: x == 2) == -1


def test_unique() -> None:
    assert unique([1, 1, 1, 2]) == [1, 2]

    def x() -> None:
        pass

    def y() -> None:
        pass

    unique_functions = unique([x, x, y, y])
    assert unique_functions == [x, y] or [y, x]
    my_list: list = []
    assert sorted(unique([my_list, my_list, my_list])) == sorted([my_list])