mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-41842: Add codecs.unregister() function (GH-22360)
Add codecs.unregister() and PyCodec_Unregister() functions to unregister a codec search function.
This commit is contained in:
parent
24ba3b0df5
commit
d332e7b816
11 changed files with 108 additions and 5 deletions
|
@ -1641,6 +1641,18 @@ class CodecsModuleTest(unittest.TestCase):
|
|||
self.assertRaises(TypeError, codecs.register)
|
||||
self.assertRaises(TypeError, codecs.register, 42)
|
||||
|
||||
def test_unregister(self):
|
||||
name = "nonexistent_codec_name"
|
||||
search_function = mock.Mock()
|
||||
codecs.register(search_function)
|
||||
self.assertRaises(TypeError, codecs.lookup, name)
|
||||
search_function.assert_called_with(name)
|
||||
search_function.reset_mock()
|
||||
|
||||
codecs.unregister(search_function)
|
||||
self.assertRaises(LookupError, codecs.lookup, name)
|
||||
search_function.assert_not_called()
|
||||
|
||||
def test_lookup(self):
|
||||
self.assertRaises(TypeError, codecs.lookup)
|
||||
self.assertRaises(LookupError, codecs.lookup, "__spam__")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue