bpo-41919, test_codecs: Move codecs.register calls to setUp() (GH-22513)

* Move the codecs' (un)register operation to testcases.
* Remove _codecs._forget_codec() and _PyCodec_Forget()
This commit is contained in:
Hai Shi 2020-10-16 16:34:15 +08:00 committed by GitHub
parent cf693e537d
commit c9f696cb96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 112 deletions

View file

@ -20,12 +20,15 @@ def codec_search_function(encoding):
return tuple(testcodec.getregentry())
return None
codecs.register(codec_search_function)
# test codec's name (see test/testcodec.py)
codecname = 'testcodec'
class CharmapCodecTest(unittest.TestCase):
def setUp(self):
codecs.register(codec_search_function)
self.addCleanup(codecs.unregister, codec_search_function)
def test_constructorx(self):
self.assertEqual(str(b'abc', codecname), 'abc')
self.assertEqual(str(b'xdef', codecname), 'abcdef')