예제 #1
0
파일: test_dict.py 프로젝트: suned/pfun
def test_get_missing_key(d):
    assume('key' not in d)

    with pytest.raises(KeyError):
        d['key']
    assert d.get('key') == Nothing()
예제 #2
0
파일: test_maybe.py 프로젝트: impurist/pfun
 def test_maybe_decorater(self):
     maybe_int = maybe(int)
     assert maybe_int('1') == Just(1)
     assert maybe_int('whoops') == Nothing()
예제 #3
0
파일: test_maybe.py 프로젝트: impurist/pfun
 def test_nothing_bool(self):
     assert not bool(Nothing())
예제 #4
0
파일: test_maybe.py 프로젝트: impurist/pfun
 def test_nothing_or_else(self, value):
     assert Nothing().or_else(value) is value
예제 #5
0
파일: test_maybe.py 프로젝트: impurist/pfun
 def test_composition_law(self, f: Unary, g: Unary, value):
     h = compose(f, g)
     assert Just(value).map(h) == Just(value).map(g).map(f)
     assert Nothing().map(h) == Nothing().map(g).map(f)
예제 #6
0
파일: test_maybe.py 프로젝트: impurist/pfun
 def _test_nothing_identity_law(self):
     assert Nothing().map(identity) == Nothing()
예제 #7
0
파일: test_maybe.py 프로젝트: impurist/pfun
 def _test_just_inequality(self, value):
     assert Just(value) != Nothing()
예제 #8
0
파일: test_maybe.py 프로젝트: impurist/pfun
 def _test_nothing_equality(self):
     assert Nothing() == Nothing()