Beispiel #1
0
    def test_stack_safety(self):
        with recursion_limit(100):
            effect.sequence_async([effect.success(v)
                                   for v in range(500)]).run(None)

        e = effect.error('')
        for _ in range(500):
            e = e.recover(lambda _: effect.error(''))
        e = e.recover(lambda _: effect.success(''))
        with recursion_limit(100):
            e.run(None)

        e = effect.success('')
        for _ in range(500):
            e = e.either()
        with recursion_limit(100):
            e.run(None)
Beispiel #2
0
 def test_resources_are_unique(self):
     mock_resource = asynctest.MagicMock()
     resource = Resource(lambda: either.Right(mock_resource))
     r1, r2 = effect.sequence_async(
         (resource.get(), resource.get())
     ).run(None)
     assert r1 is r2
     mock_resource.__aenter__.assert_called_once()
Beispiel #3
0
 def test_sequence_generator(self):
     e = effect.sequence_async(effect.success(v) for v in range(3))
     assert e.run(None) == (0, 1, 2)
     assert e.run(None) == (0, 1, 2)
Beispiel #4
0
 def test_sequence(self):
     assert effect.sequence_async([effect.success(v) for v in range(3)]
                                  ).run(None) == (0, 1, 2)
Beispiel #5
0
 def test_sequence_async_repr(self):
     e = effect.sequence_async([effect.success(0)])
     assert (repr(e)) == 'sequence_async((success(0),))'