コード例 #1
0
ファイル: test_maybe_equality.py プロジェクト: chkoar/returns
def test_is_compare():
    """Ensures that `is` operator works correctly."""
    some_container = Some(1)

    assert Nothing.bind(lambda state: state) is Nothing
    assert some_container.rescue(lambda: Some('fix')) is some_container
    assert some_container is not Some(1)
コード例 #2
0
def test_bind_nothing():
    """Ensures that left identity works for Nothing container."""
    def factory(inner_value) -> Maybe[int]:
        return Some(1)

    bound = Nothing.bind(factory)

    assert bound == Nothing
    assert str(bound) == '<Nothing>'