コード例 #1
0
ファイル: test_apply.py プロジェクト: t94j0/returns
def test_apply_with_context_ioresult():
    """Ensures that functions can be composed and return type is correct."""
    applied = apply(RequiresContextIOResult.from_value(_function))

    assert applied(RequiresContextIOResult.from_value(1), )(
        ...) == IOSuccess('2')
コード例 #2
0
ファイル: test_apply.py プロジェクト: t94j0/returns
def test_apply_with_context():
    """Ensures that functions can be composed and return type is correct."""
    applied = apply(RequiresContext.from_value(_function))

    assert applied(RequiresContext.from_value(1))(...) == '2'
コード例 #3
0
ファイル: test_apply.py プロジェクト: t94j0/returns
def test_apply_with_maybe():
    """Ensures that functions can be composed and return type is correct."""
    applied = apply(Maybe.from_value(_function))

    assert applied(Some(1)) == Some('2')
    assert applied(Nothing) == Nothing
コード例 #4
0
ファイル: test_apply.py プロジェクト: t94j0/returns
def test_apply_with_result():
    """Ensures that functions can be composed and return type is correct."""
    applied = apply(Result.from_value(_function))

    assert applied(Success(1)) == Success('2')
    assert applied(Failure('s')) == Failure('s')
コード例 #5
0
ファイル: test_apply.py プロジェクト: t94j0/returns
def test_apply_with_io():
    """Ensures that functions can be composed and return type is correct."""
    assert apply(IO(_function))(IO(1)) == IO('2')