summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_types.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 7b45b7a..544c91b 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -622,8 +622,11 @@ class MappingProxyTests(unittest.TestCase):
self.assertEqual(attrs, {
'__contains__',
'__getitem__',
+ '__ior__',
'__iter__',
'__len__',
+ '__or__',
+ '__ror__',
'copy',
'get',
'items',
@@ -774,6 +777,22 @@ class MappingProxyTests(unittest.TestCase):
self.assertEqual(view['key1'], 70)
self.assertEqual(copy['key1'], 27)
+ def test_union(self):
+ mapping = {'a': 0, 'b': 1, 'c': 2}
+ view = self.mappingproxy(mapping)
+ with self.assertRaises(TypeError):
+ view | [('r', 2), ('d', 2)]
+ with self.assertRaises(TypeError):
+ [('r', 2), ('d', 2)] | view
+ with self.assertRaises(TypeError):
+ view |= [('r', 2), ('d', 2)]
+ other = {'c': 3, 'p': 0}
+ self.assertDictEqual(view | other, {'a': 0, 'b': 1, 'c': 3, 'p': 0})
+ self.assertDictEqual(other | view, {'c': 2, 'p': 0, 'a': 0, 'b': 1})
+ self.assertEqual(view, {'a': 0, 'b': 1, 'c': 2})
+ self.assertDictEqual(mapping, {'a': 0, 'b': 1, 'c': 2})
+ self.assertDictEqual(other, {'c': 3, 'p': 0})
+
class ClassCreationTests(unittest.TestCase):