File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 11"""Tests for the Tools/i18n/msgfmt.py tool.""" 
22
33import  json 
4+ import  struct 
45import  sys 
56import  unittest 
67from  gettext  import  GNUTranslations 
@@ -40,6 +41,28 @@ def test_compilation(self):
4041
4142                    self .assertDictEqual (actual ._catalog , expected ._catalog )
4243
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+ 
4366    def  test_translations (self ):
4467        with  open (data_dir  /  'general.mo' , 'rb' ) as  f :
4568            t  =  GNUTranslations (f )
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments