Skip to content

Commit

Permalink
Fix Dispatcher tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipVinc committed Sep 30, 2023
1 parent 0ada36f commit 89ddb03
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def g(x: float):
pass

assert set(dispatch.functions.keys()) == {"f", "g"}
assert dispatch.functions["f"].methods[0] == Signature(int)
assert dispatch.functions["g"].methods[0] == Signature(float)
assert dispatch.functions["g"].methods[0].precedence == 1
assert dispatch.functions["f"].methods[0].signature == Signature(int)
assert dispatch.functions["g"].methods[0].signature == Signature(
float, precedence=1
)


def test_dispatch_class():
Expand All @@ -37,9 +38,10 @@ def g(x: float):
a = "tests.test_dispatcher.test_dispatch_class.<locals>.A"
b = "tests.test_dispatcher.test_dispatch_class.<locals>.B"
assert set(dispatch.classes.keys()) == {a, b}
assert dispatch.classes[a]["f"].methods[0] == Signature(int)
assert dispatch.classes[b]["g"].methods[0] == Signature(float)
assert dispatch.classes[b]["g"].methods[0].precedence == 1
assert dispatch.classes[a]["f"].methods[0].signature == Signature(int)
assert dispatch.classes[b]["g"].methods[0].signature == Signature(
float, precedence=1
)


def test_dispatch_multi():
Expand All @@ -56,7 +58,7 @@ def f(x):
assert f(1) == "int"
assert f(1.0) == "float or str"
assert f("1") == "float or str"
assert dispatch.functions["f"].methods[2].precedence == 1
assert dispatch.functions["f"].methods[2].signature.precedence == 1

# Check that arguments to `dispatch.multi` must be tuples or signatures.
with pytest.raises(ValueError):
Expand Down

0 comments on commit 89ddb03

Please sign in to comment.