Skip to content

Commit 9fef36c

Browse files
AlexanderGrooffbrandonwillard
authored andcommitted
Test both unify and reifying nonstandard objects
Change from the previous commit only affects reifying nonstandard objects, so this change better reflects the new situation. Use the base `unify` and `reify` functions to test instead of the private functions.
1 parent a66b84a commit 9fef36c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/test_more.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ast import Num
1+
import ast
22
from collections.abc import Mapping
33

44
from unification import var
@@ -31,10 +31,11 @@ def test_unify_object():
3131

3232

3333
def test_unify_nonstandard_object():
34+
_unify.add((ast.AST, ast.AST, Mapping), _unify_object)
3435
x = var()
35-
assert stream_eval(_unify_object(Num(n=1), Num(n=1), {})) == {}
36-
assert stream_eval(_unify_object(Num(n=1), Num(n=2), {})) is False
37-
assert stream_eval(_unify_object(Num(n=1), Num(n=x), {})) == {x: 1}
36+
assert unify(ast.Num(n=1), ast.Num(n=1), {}) == {}
37+
assert unify(ast.Num(n=1), ast.Num(n=2), {}) is False
38+
assert unify(ast.Num(n=1), ast.Num(n=x), {}) == {x: 1}
3839

3940

4041
def test_reify_object():
@@ -47,6 +48,14 @@ def test_reify_object():
4748
assert stream_eval(_reify_object(f, {})) is f
4849

4950

51+
def test_reify_nonstandard_object():
52+
_reify.add((ast.AST, Mapping), _reify_object)
53+
x = var()
54+
assert reify(ast.Num(n=1), {}).n == 1
55+
assert reify(ast.Num(n=x), {}).n == x
56+
assert reify(ast.Num(n=x), {x: 2}).n == 2
57+
58+
5059
def test_reify_slots():
5160
class SlotsObject(object):
5261
__slots__ = ["myattr"]

0 commit comments

Comments
 (0)