Skip to content

Commit

Permalink
Fix union of frozendict for python implementation (#89)
Browse files Browse the repository at this point in the history
* Fix union of frozendict for python implementation

* minor

---------

Co-authored-by: Marco Sulla <github@marco.sulla.e4ward.com>
  • Loading branch information
apmorton and Marco-Sulla authored Nov 18, 2023
1 parent 1cf399f commit db44acb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/frozendict/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,8 @@ def frozendict_or(self, other, *args, **kwargs):

return self.__class__(res)



try:
frozendict.__or__
except AttributeError:
frozendict.__or__ = frozendict_or

frozendict.__ior__ = frozendict.__or__
frozendict.__or__ = frozendict_or
frozendict.__ior__ = frozendict_or

try:
frozendict.__reversed__
Expand Down
2 changes: 2 additions & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_iter(self, fd):

def test_sum(self, fd, fd_dict, fd_dict_sabina):
new_fd = fd | fd_dict_sabina
assert type(new_fd) is self.FrozendictClass
new_dict = dict(fd_dict)
new_dict.update(fd_dict_sabina)
assert new_fd == new_dict
Expand All @@ -178,6 +179,7 @@ def test_union(self, fd_dict, fd_sabina):
new_fd = self.FrozendictClass(fd_dict)
id_fd = id(new_fd)
new_fd |= fd_sabina
assert type(new_fd) is self.FrozendictClass
assert id_fd != id(new_fd)
new_dict = dict(fd_dict)
new_dict.update(fd_sabina)
Expand Down

0 comments on commit db44acb

Please sign in to comment.