Repository: zopefoundation/zope.i18n (language: python)

Issue:
Tests are broken on master because of zope.i18nmessageid >= 7.0
Traceback:

```python
Error in test testMessageIDRecursiveTranslate (zope.i18n.tests.test_translationdomain.TestGlobalTranslationDomain.testMessageIDRecursiveTranslate)
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/unittest/case.py", line 57, in testPartExecutor
    yield
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/unittest/case.py", line 623, in run
    self._callTestMethod(testMethod)
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/unittest/case.py", line 579, in _callTestMethod
    if method() is not None:
  File "/home/runner/work/zope.i18n/zope.i18n/src/zope/i18n/tests/test_translationdomain.py", line 116, in testMessageIDRecursiveTranslate
    msgid1.mapping['msg2'] = msgid2
TypeError: 'mappingproxy' object does not support item assignment
```

See https://github.com/zopefoundation/zope.i18n/actions/runs/10980960593/job/30487405136

There were several packages updated but I bisected it to the update of `zope.i18nmessageid`, requiring a version `< 7` makes the tests pass.


Discussion / hints:
I think the test is wrong: message ids should be hashable with a persistent hash. In general, this implies that they cannot be changed after creation. The test modifies the `mapping` attribute of the message id likely violating the persistent hash condition.

I will try to verify my thought.
https://github.com/zopefoundation/zope.i18nmessageid/blob/2fea1d9944d7eb10f8b9c97e3853cd517f5c43a9/docs/narr.rst?plain=1#L94
clearly tells that message ids are designed to be immutable; i.e. its attributes must not be changed after creation.

Apparently, previous (< 7) versions of `zope.i18nmessageid` have not enforced this fully.
Okay, this means: Let's fix the test.
Let me give it a try.

Fix patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index f2af313..36dfb53 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -9,6 +9,9 @@
 
 - Drop support for Python 3.7.
 
+- Fix test incompatibility for ``zope.i18nmessageid >= 7.0``
+  (`#62 <https://github.com/zopefoundation/zope.i18n/issues/62>`_).
+
 
 5.1 (2023-08-28)
 ================


Test patch:
diff --git a/src/zope/i18n/tests/test_translationdomain.py b/src/zope/i18n/tests/test_translationdomain.py
index 45c2e82..623efa1 100644
--- a/src/zope/i18n/tests/test_translationdomain.py
+++ b/src/zope/i18n/tests/test_translationdomain.py
@@ -113,10 +113,17 @@ def testMessageIDRecursiveTranslate(self):
                          mapping={})
         msgid2 = factory("48-not-there", 'Message 2 and $msg1',
                          mapping={})
-        msgid1.mapping['msg2'] = msgid2
-        msgid2.mapping['msg1'] = msgid1
-        self.assertRaises(ValueError,
-                          translate, msgid1, None, None, 'en', "default")
+        try:
+            msgid1.mapping['msg2'] = msgid2
+            msgid2.mapping['msg1'] = msgid1
+        except TypeError:
+            # this is a `zope.i118nmessageid >= 7` message id enforcing
+            # immutability; circular references therefore
+            # cannot be created in this way
+            pass
+        else:
+            self.assertRaises(ValueError,
+                              translate, msgid1, None, None, 'en', "default")
         # Recursive translations also work if the original message id wasn't a
         # message id but a Unicode with a directly passed mapping
         self.assertEqual(