mirror of
https://github.com/python/cpython.git
synced 2026-05-06 12:49:07 -04:00
gh-141510: Fix frozendict.items() ^ frozendict.items() (#145535)
Add non-regression tests.
This commit is contained in:
@@ -1848,11 +1848,19 @@ class FrozenDictTests(unittest.TestCase):
|
||||
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 @@ class FrozenDictTests(unittest.TestCase):
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user