Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
e = e.recover(lambda _: effect.success(''))
with recursion_limit(100):
def test_composition_law(self, f, g, value, env):
h = compose(f, g)
assert (
effect.success(value).map(h).run(env) ==
effect.success(value).map(g).map(f).run(env)
)
def test_sequence(self):
assert effect.sequence_async([effect.success(v) for v in range(3)]
).run(None) == (0, 1, 2)
def test_identity_law(self, value, env):
assert (
effect.success(value).map(identity).run(env) ==
effect.success(value).run(env)
)
def test_equality(self, value, env):
assert effect.success(value).run(env) == effect.success(value).run(env)
def test_left_identity_law(self, f, value, env):
assert (
effect.success(value).and_then(f).run(env) == f(value).run(env)
)
def effects(value_strategy=anything()):
return builds(effect.success, value_strategy)
def test_inequality(self, first, second, env):
assume(first != second)
assert effect.success(first).run(env) != effect.success(second
).run(env)
assert effect.filter_m(lambda v: effect.success(v % 2 == 0),
range(5)).run(None) == (0, 2, 4)
async def _fetch(connection: asyncpg.Connection
) -> Try[asyncpg.PostgresError, Results]:
try:
result = await connection.fetch(query, *args, timeout=timeout)
result = List(Dict(record) for record in result)
return success(result)
except asyncpg.PostgresError as e:
return error(e)