Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test
  • Loading branch information
StanFromIreland committed Mar 28, 2025
commit 8213a012660e86a76e8e2dd474504d66d6d3103f
23 changes: 23 additions & 0 deletions Lib/test/test_tools/test_msgfmt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for the Tools/i18n/msgfmt.py tool."""

import json
import struct
import sys
import unittest
from gettext import GNUTranslations
Expand Down Expand Up @@ -40,6 +41,28 @@ def test_compilation(self):

self.assertDictEqual(actual._catalog, expected._catalog)

def test_binary_header(self):
with open(data_dir / "general.mo", "rb") as f:
mo_data = f.read()

(
magic,
version,
num_strings,
orig_table_offset,
trans_table_offset,
hash_table_size,
hash_table_offset,
) = struct.unpack("Iiiiiii", mo_data[:28])
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated

self.assertEqual(magic, 0x950412de)
self.assertEqual(version, 0)
self.assertEqual(num_strings, 9)
self.assertEqual(orig_table_offset, 28)
self.assertEqual(trans_table_offset, 100)
self.assertEqual(hash_table_size, 0)
self.assertEqual(hash_table_offset, 0)

def test_translations(self):
with open(data_dir / 'general.mo', 'rb') as f:
t = GNUTranslations(f)
Expand Down
Loading