File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1
1
"""Tests for the Tools/i18n/msgfmt.py tool."""
2
2
3
3
import json
4
+ import struct
4
5
import sys
5
6
import unittest
6
7
from gettext import GNUTranslations
@@ -40,6 +41,28 @@ def test_compilation(self):
40
41
41
42
self .assertDictEqual (actual ._catalog , expected ._catalog )
42
43
44
+ def test_binary_header (self ):
45
+ with open (data_dir / "general.mo" , "rb" ) as f :
46
+ mo_data = f .read ()
47
+
48
+ (
49
+ magic ,
50
+ version ,
51
+ num_strings ,
52
+ orig_table_offset ,
53
+ trans_table_offset ,
54
+ hash_table_size ,
55
+ hash_table_offset ,
56
+ ) = struct .unpack ("=Iiiiiii" , mo_data [:28 ])
57
+
58
+ self .assertEqual (magic , 0x950412de )
59
+ self .assertEqual (version , 0 )
60
+ self .assertEqual (num_strings , 9 )
61
+ self .assertEqual (orig_table_offset , 28 )
62
+ self .assertEqual (trans_table_offset , 100 )
63
+ self .assertEqual (hash_table_size , 0 )
64
+ self .assertEqual (hash_table_offset , 0 )
65
+
43
66
def test_translations (self ):
44
67
with open (data_dir / 'general.mo' , 'rb' ) as f :
45
68
t = GNUTranslations (f )
You can’t perform that action at this time.
0 commit comments