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

Method test_binary_header

Lib/test/test_tools/test_msgfmt.py:47–70  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

45 self.assertDictEqual(actual._catalog, expected._catalog)
46
47 def test_binary_header(self):
48 with temp_cwd():
49 tmp_mo_file = 'messages.mo'
50 compile_messages(data_dir / "general.po", tmp_mo_file)
51 with open(tmp_mo_file, 'rb') as f:
52 mo_data = f.read()
53
54 (
55 magic,
56 version,
57 num_strings,
58 orig_table_offset,
59 trans_table_offset,
60 hash_table_size,
61 hash_table_offset,
62 ) = struct.unpack("=7I", mo_data[:28])
63
64 self.assertEqual(magic, 0x950412de)
65 self.assertEqual(version, 0)
66 self.assertEqual(num_strings, 9)
67 self.assertEqual(orig_table_offset, 28)
68 self.assertEqual(trans_table_offset, 100)
69 self.assertEqual(hash_table_size, 0)
70 self.assertEqual(hash_table_offset, 0)
71
72 def test_translations(self):
73 with open(data_dir / 'general.mo', 'rb') as f:

Callers

nothing calls this directly

Calls 6

temp_cwdFunction · 0.90
compile_messagesFunction · 0.85
unpackMethod · 0.80
openFunction · 0.50
readMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected