File: test_partition.py

package info (click to toggle)
python-returns 0.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,652 kB
  • sloc: python: 11,000; makefile: 18
file content (34 lines) | stat: -rw-r--r-- 881 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
34
import pytest

from returns.io import IO, IOResult
from returns.maybe import Nothing, Some
from returns.methods import partition
from returns.result import Failure, Success


@pytest.mark.parametrize(
    ('containers', 'expected'),
    [
        (
            (Success(1), Success(2), Failure(None), Success(3)),
            ([1, 2, 3], [None]),
        ),
        (
            (
                IOResult.from_value(1),
                IOResult.from_failure(2),
                IOResult.from_value(3),
                IOResult.from_failure(4),
            ),
            ([IO(1), IO(3)], [IO(2), IO(4)]),  # noqa: WPS221
        ),
        (
            (Some(1), Some(2), Nothing),
            ([1, 2], [None]),
        ),
        ((), ([], [])),
    ],
)
def test_partition(containers, expected):
    """Test partition function."""
    assert partition(containers) == expected