File: test_542_itertools.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (53 lines) | stat: -rw-r--r-- 1,348 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
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
# Copyright (c) 2024, Manfred Moitzi
# License: MIT License
# pylint: disable=all
import pytest

from ezdxf.tools import take2, pairwise


class TestTake2:
    def test_empty_list(self):
        assert len(list(take2([]))) == 0

    def test_1_item(self):
        assert len(list(take2([1]))) == 0

    def test_2_items(self):
        assert list(take2([1, 2])) == [(1, 2)]

    def test_3_items(self):
        assert list(take2([1, 2, 3])) == [(1, 2)]

    def test_4_items(self):
        assert list(take2([1, 2, 3, 4])) == [(1, 2), (3, 4)]

class TestPairwiseOpen:
    def test_empty_list(self):
        assert len(list(pairwise([]))) == 0

    def test_1_item(self):
        assert len(list(pairwise([1]))) == 0

    def test_2_items(self):
        assert list(pairwise([1, 2])) == [(1, 2)]

    def test_3_items(self):
        assert list(pairwise([1, 2, 3])) == [(1, 2), (2, 3)]

class TestPairwiseClose:
    def test_empty_list(self):
        assert len(list(pairwise([], close=True))) == 0

    def test_1_item(self):
        assert len(list(pairwise([1], close=True))) == 0

    def test_2_items(self):
        assert list(pairwise([1, 2], close=True)) == [(1, 2), (2, 1)]

    def test_3_items(self):
        assert list(pairwise([1, 2, 3], close=True)) == [(1, 2), (2, 3), (3, 1)]


if __name__ == '__main__':
    pytest.main([__file__])