aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst4
-rw-r--r--immutables/_map.c2
-rw-r--r--immutables/map.py4
-rw-r--r--tests/test_map.py22
4 files changed, 16 insertions, 16 deletions
diff --git a/README.rst b/README.rst
index 4f3d789..203f529 100644
--- a/README.rst
+++ b/README.rst
@@ -82,7 +82,7 @@ Maps also implement APIs for bulk updates: ``MapMutation`` objects::
del map_mutation['b']
map_mutation.set('y', 'y')
- map2 = map_mutation.finalize()
+ map2 = map_mutation.finish()
print(map, map2)
# will print:
@@ -96,7 +96,7 @@ rewritten in a more idiomatic way::
mm['a'] = 100
del mm['b']
mm.set('y', 'y')
- map2 = mm.finalize()
+ map2 = mm.finish()
print(map, map2)
# will print:
diff --git a/immutables/_map.c b/immutables/_map.c
index 652e171..d5d7f97 100644
--- a/immutables/_map.c
+++ b/immutables/_map.c
@@ -3969,7 +3969,7 @@ static PyMethodDef MapMutation_methods[] = {
{"set", (PyCFunction)mapmut_py_set, METH_VARARGS, NULL},
{"get", (PyCFunction)map_py_get, METH_VARARGS, NULL},
{"pop", (PyCFunction)mapmut_py_pop, METH_VARARGS, NULL},
- {"finalize", (PyCFunction)mapmut_py_finalize, METH_NOARGS, NULL},
+ {"finish", (PyCFunction)mapmut_py_finalize, METH_NOARGS, NULL},
{"__enter__", (PyCFunction)mapmut_py_enter, METH_NOARGS, NULL},
{"__exit__", (PyCFunction)mapmut_py_exit, METH_VARARGS, NULL},
{NULL, NULL}
diff --git a/immutables/map.py b/immutables/map.py
index fbe6562..a393b72 100644
--- a/immutables/map.py
+++ b/immutables/map.py
@@ -637,7 +637,7 @@ class MapMutation:
return self
def __exit__(self, *exc):
- self.finalize()
+ self.finish()
return False
def __delitem__(self, key):
@@ -707,7 +707,7 @@ class MapMutation:
else:
return True
- def finalize(self):
+ def finish(self):
self.__mutid = 0
return Map._new(self.__count, self.__root)
diff --git a/tests/test_map.py b/tests/test_map.py
index d3b11fb..69684e8 100644
--- a/tests/test_map.py
+++ b/tests/test_map.py
@@ -943,8 +943,8 @@ class BaseMapTest:
self.assertEqual(hm2['a'], 1000)
self.assertTrue('x' in hm2)
- h1 = hm1.finalize()
- h2 = hm2.finalize()
+ h1 = hm1.finish()
+ h2 = hm2.finish()
self.assertTrue(isinstance(h1, self.Map))
@@ -960,7 +960,7 @@ class BaseMapTest:
hm1.set('a', 2)
hm1.set('a', 3)
hm1.set('a', 4)
- h2 = hm1.finalize()
+ h2 = hm1.finish()
self.assertEqual(dict(h.items()), {'a': 1})
self.assertEqual(dict(h2.items()), {'a': 4})
@@ -1124,22 +1124,22 @@ class BaseMapTest:
mm = m.mutate()
self.assertEqual(mm.pop('a', 1), 1)
- self.assertEqual(mm.finalize(), self.Map({'b': 2}))
+ self.assertEqual(mm.finish(), self.Map({'b': 2}))
mm = m.mutate()
self.assertEqual(mm.pop('b', 1), 2)
- self.assertEqual(mm.finalize(), self.Map({'a': 1}))
+ self.assertEqual(mm.finish(), self.Map({'a': 1}))
mm = m.mutate()
self.assertEqual(mm.pop('b', 1), 2)
del mm['a']
- self.assertEqual(mm.finalize(), self.Map())
+ self.assertEqual(mm.finish(), self.Map())
def test_map_mut_12(self):
m = self.Map({'a': 1, 'b': 2})
mm = m.mutate()
- mm.finalize()
+ mm.finish()
with self.assertRaisesRegex(ValueError, 'has been finalized'):
mm.pop('a')
@@ -1181,7 +1181,7 @@ class BaseMapTest:
mm['z'] = 100
del mm['a']
- self.assertEqual(mm.finalize(), self.Map(z=100, b=2))
+ self.assertEqual(mm.finish(), self.Map(z=100, b=2))
def test_map_mut_15(self):
m = self.Map(a=1, b=2)
@@ -1192,7 +1192,7 @@ class BaseMapTest:
del mm['a']
1 / 0
- self.assertEqual(mm.finalize(), self.Map(z=100, b=2))
+ self.assertEqual(mm.finish(), self.Map(z=100, b=2))
self.assertEqual(m, self.Map(a=1, b=2))
def test_map_mut_stress(self):
@@ -1216,7 +1216,7 @@ class BaseMapTest:
self.assertEqual(len(hm), len(d))
- h2 = hm.finalize()
+ h2 = hm.finish()
self.assertEqual(dict(h2.items()), d)
h = h2
@@ -1238,7 +1238,7 @@ class BaseMapTest:
self.assertEqual(len(hm), len(d))
- h2 = hm.finalize()
+ h2 = hm.finish()
self.assertEqual(dict(h2.items()), d)
h = h2