MCPcopy
hub / github.com/dry-python/returns / assert_equal

Function assert_equal

returns/primitives/asserts.py:1–34  ·  view source on GitHub ↗

Custom ``assert`` function to compare two any containers. The important note here is that this ``assert`` should probably used in tests. Not real application code. It will call all ``Reader`` based containers and ``await`` all ``Future`` based ones. It also works recu

(
    first,
    second,
    *,
    deps=None,
    backend: str = 'asyncio',
)

Source from the content-addressed store, hash-verified

1def assert_equal(
2 first,
3 second,
4 *,
5 deps=None,
6 backend: str = 'asyncio',
7) -> None:
8 """
9 Custom ``assert`` function to compare two any containers.
10
11 The important note here is that
12 this ``assert`` should probably used in tests.
13 Not real application code.
14
15 It will call all ``Reader`` based containers and ``await``
16 all ``Future`` based ones.
17
18 It also works recursively.
19 For example, ``ReaderFutureResult`` will be called and then awaited.
20
21 You can specify different dependencies to call your containers.
22 And different backends to ``await`` then using ``anyio``.
23
24 By the way, ``anyio`` should be installed separately.
25 """
26 assert _convert(
27 first,
28 deps=deps,
29 backend=backend,
30 ) == _convert(
31 second,
32 deps=deps,
33 backend=backend,
34 ), f'{first} == {second}'
35
36
37def _convert(container, *, deps, backend: str):

Callers 15

assert_equalMethod · 0.90
identity_lawMethod · 0.90
interchange_lawMethod · 0.90
homomorphism_lawMethod · 0.90
composition_lawMethod · 0.90
map_short_circuit_lawMethod · 0.90
map_short_circuit_lawMethod · 0.90

Calls 1

_convertFunction · 0.85

Tested by 7

pair_equality_lawMethod · 0.72
test_assert_equalFunction · 0.72
test_assert_equal_notFunction · 0.72
identity_lawMethod · 0.72
associative_lawMethod · 0.72
idempotence_lawMethod · 0.72