コード例 #1
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_iter():
    obj = object()
    assert list(Just(obj)) == [obj]
コード例 #2
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_add_monoid_empty():
    obj = object()
    value = Just(obj)
    assert value + mempty(value) == value
コード例 #3
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_repr_conatins_subobject():
    obj = object()
    assert repr(obj) in repr(Just(obj))
コード例 #4
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_add_Nothing():
    obj = object()
    assert Just(obj) + Nothing() == Just(obj)
コード例 #5
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_add_Just():
    assert Just([1]) + Just([2]) == Just([1, 2])
コード例 #6
0
def test_IsomorphismLens_unpack():
    assert b.Isomorphism(int, str).unpack('1') == Just(1)
コード例 #7
0
def test_Nothing_fromiter():
    assert lenses.setter.fromiter(Just(1), []) == Nothing()
コード例 #8
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_equals_Just_when_subobjects_equal():
    # maybe hypothesis can make this more rigourous
    obj1 = object()
    obj2 = object()
    assert (Just(obj1) == Just(obj2)) is bool(obj1 == obj2)
コード例 #9
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_not_equals_Nothing():
    assert Just(object()) != Nothing()
コード例 #10
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Nothing_from_iter():
    assert lenses.hooks.from_iter(Just(1), []) == Nothing()
コード例 #11
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Nothing_not_equals_Just():
    assert Nothing() != Just(object())
コード例 #12
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Nothing_add_Just():
    obj = object()
    assert Nothing() + Just(obj) == Just(obj)
コード例 #13
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_unwrap():
    obj = object()
    assert Just(obj).unwrap() is obj
コード例 #14
0
def test_Just_fromiter():
    obj = object()
    assert lenses.setter.fromiter(Nothing(), [obj]) == Just(obj)
コード例 #15
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_from_iter():
    obj = object()
    assert lenses.hooks.from_iter(Nothing(), [obj]) == Just(obj)
コード例 #16
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_not_equals_object():
    obj = object
    assert Just(obj) != obj
コード例 #17
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_maybe():
    obj = object()
    assert Just(obj).maybe() is obj
コード例 #18
0
ファイル: test_maybe.py プロジェクト: yetone/python-lenses
def test_Just_map():
    assert Just(1).map(str) == Just(str(1))
コード例 #19
0
def test_prism_folder_success():
    obj = object
    assert list(b.JustPrism().folder(Just(obj))) == [obj]
コード例 #20
0
def test_traversal_just_using_identity():
    assert tc.traverse(Just(1), ident) == Identity(Just(4))