mirror of
https://github.com/python/cpython.git
synced 2026-04-14 15:50:50 +00:00
gh-141510: Fix frozendict.items() ^ frozendict.items() (#145535)
Add non-regression tests.
This commit is contained in:
parent
11840ca99a
commit
2cd0ddfe04
2 changed files with 14 additions and 1 deletions
|
|
@ -1848,11 +1848,19 @@ def test_merge(self):
|
|||
frozendict({'x': 1, 'y': 2}))
|
||||
self.assertEqual(frozendict(x=1, y=2) | frozendict(y=5),
|
||||
frozendict({'x': 1, 'y': 5}))
|
||||
self.assertEqual(FrozenDict(x=1, y=2) | FrozenDict(y=5),
|
||||
frozendict({'x': 1, 'y': 5}))
|
||||
|
||||
fd = frozendict(x=1, y=2)
|
||||
self.assertIs(fd | frozendict(), fd)
|
||||
self.assertIs(fd | {}, fd)
|
||||
self.assertIs(frozendict() | fd, fd)
|
||||
|
||||
fd = FrozenDict(x=1, y=2)
|
||||
self.assertEqual(fd | frozendict(), fd)
|
||||
self.assertEqual(fd | {}, fd)
|
||||
self.assertEqual(frozendict() | fd, fd)
|
||||
|
||||
def test_update(self):
|
||||
# test "a |= b" operator
|
||||
d = frozendict(x=1)
|
||||
|
|
@ -1863,6 +1871,11 @@ def test_update(self):
|
|||
self.assertEqual(d, frozendict({'x': 1, 'y': 2}))
|
||||
self.assertEqual(copy, frozendict({'x': 1}))
|
||||
|
||||
def test_items_xor(self):
|
||||
# test "a ^ b" operator on items views
|
||||
res = frozendict(a=1, b=2).items() ^ frozendict(b=2, c=3).items()
|
||||
self.assertEqual(res, {('a', 1), ('c', 3)})
|
||||
|
||||
def test_repr(self):
|
||||
d = frozendict()
|
||||
self.assertEqual(repr(d), "frozendict()")
|
||||
|
|
|
|||
|
|
@ -6523,7 +6523,7 @@ dictitems_xor_lock_held(PyObject *d1, PyObject *d2)
|
|||
ASSERT_DICT_LOCKED(d1);
|
||||
ASSERT_DICT_LOCKED(d2);
|
||||
|
||||
PyObject *temp_dict = copy_lock_held(d1, PyFrozenDict_Check(d1));
|
||||
PyObject *temp_dict = copy_lock_held(d1, 0);
|
||||
if (temp_dict == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue