diff options
Diffstat (limited to 'Lib/test/test_threading_local.py')
-rw-r--r-- | Lib/test/test_threading_local.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py index f0b829a..3a58afd 100644 --- a/Lib/test/test_threading_local.py +++ b/Lib/test/test_threading_local.py @@ -208,6 +208,21 @@ class BaseLocalTest: _testcapi.join_temporary_c_thread() + @support.cpython_only + def test_error(self): + class Loop(self._local): + attr = 1 + + # Trick the "if name == '__dict__':" test of __setattr__() + # to always be true + class NameCompareTrue: + def __eq__(self, other): + return True + + loop = Loop() + with self.assertRaisesRegex(AttributeError, 'Loop.*read-only'): + loop.__setattr__(NameCompareTrue(), 2) + class ThreadLocalTest(unittest.TestCase, BaseLocalTest): _local = _thread._local |