diff --git a/tests/test_more.py b/tests/test_more.py index 30e5a6a..38c5923 100644 --- a/tests/test_more.py +++ b/tests/test_more.py @@ -1,3 +1,4 @@ +from ast import Num from collections.abc import Mapping from unification import var @@ -29,6 +30,13 @@ def test_unify_object(): assert stream_eval(_unify_object(Foo(1, 2), Foo(1, x), {})) == {x: 2} +def test_unify_nonstandard_object(): + x = var() + assert stream_eval(_unify_object(Num(n=1), Num(n=1), {})) == {} + assert stream_eval(_unify_object(Num(n=1), Num(n=2), {})) is False + assert stream_eval(_unify_object(Num(n=1), Num(n=x), {})) == {x: 1} + + def test_reify_object(): x = var() obj = stream_eval(_reify_object(Foo(1, x), {x: 4})) diff --git a/unification/more.py b/unification/more.py index 0922284..071e638 100644 --- a/unification/more.py +++ b/unification/more.py @@ -53,7 +53,7 @@ def _reify_object(o, s): def _reify_object_dict(o, s): - obj = object.__new__(type(o)) + obj = type(o).__new__(type(o)) d = yield _reify(o.__dict__, s)