MCPcopy Index your code
hub / github.com/python/cpython / test_unpack_registry

Method test_unpack_registry

Lib/test/test_shutil.py:2197–2221  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2195 self.check_unpack_archive('zip', filter='data')
2196
2197 def test_unpack_registry(self):
2198
2199 formats = get_unpack_formats()
2200
2201 def _boo(filename, extract_dir, extra):
2202 self.assertEqual(extra, 1)
2203 self.assertEqual(filename, 'stuff.boo')
2204 self.assertEqual(extract_dir, 'xx')
2205
2206 register_unpack_format('Boo', ['.boo', '.b2'], _boo, [('extra', 1)])
2207 unpack_archive('stuff.boo', 'xx')
2208
2209 # trying to register a .boo unpacker again
2210 self.assertRaises(RegistryError, register_unpack_format, 'Boo2',
2211 ['.boo'], _boo)
2212
2213 # should work now
2214 unregister_unpack_format('Boo')
2215 register_unpack_format('Boo2', ['.boo'], _boo)
2216 self.assertIn(('Boo2', ['.boo'], ''), get_unpack_formats())
2217 self.assertNotIn(('Boo', ['.boo'], ''), get_unpack_formats())
2218
2219 # let's leave a clean state
2220 unregister_unpack_format('Boo2')
2221 self.assertEqual(get_unpack_formats(), formats)
2222
2223
2224class TestMisc(BaseTest, unittest.TestCase):

Callers

nothing calls this directly

Calls 8

get_unpack_formatsFunction · 0.90
register_unpack_formatFunction · 0.90
unpack_archiveFunction · 0.90
unregister_unpack_formatFunction · 0.90
assertInMethod · 0.80
assertNotInMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected