Ejemplo n.º 1
0
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)
Ejemplo n.º 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>'