@@ -87,7 +87,8 @@ def assert_POT_equal(self, expected, actual):
8787        self .maxDiff  =  None 
8888        self .assertEqual (normalize_POT_file (expected ), normalize_POT_file (actual ))
8989
90-     def  extract_from_str (self , module_content , * , args = (), strict = True , with_stderr = False ):
90+     def  extract_from_str (self , module_content , * , args = (), strict = True ,
91+                          with_stderr = False , raw = False ):
9192        """Return all msgids extracted from module_content.""" 
9293        filename  =  'test.py' 
9394        with  temp_cwd (None ):
@@ -98,10 +99,11 @@ def extract_from_str(self, module_content, *, args=(), strict=True, with_stderr=
9899                self .assertEqual (res .err , b'' )
99100            with  open ('messages.pot' , encoding = 'utf-8' ) as  fp :
100101                data  =  fp .read ()
101-         msgids  =  self .get_msgids (data )
102+         if  not  raw :
103+             data  =  self .get_msgids (data )
102104        if  not  with_stderr :
103-             return  msgids 
104-         return  msgids , res .err 
105+             return  data 
106+         return  data , res .err 
105107
106108    def  extract_docstrings_from_str (self , module_content ):
107109        """Return all docstrings extracted from module_content.""" 
@@ -432,6 +434,20 @@ def test_error_messages(self):
432434            "*** test.py:3: Variable positional arguments are not allowed in gettext calls\n " 
433435        )
434436
437+     def  test_extract_all_comments (self ):
438+         """ 
439+         Test that the --add-comments option without an 
440+         explicit tag extracts all translator comments. 
441+         """ 
442+ 
443+         for  arg  in  ('--add-comments' , '-c' ):
444+             with  self .subTest (arg = arg ):
445+                 data  =  self .extract_from_str (dedent ('''\  
446+ 
447+                 _("foo") 
448+                 ''' ), args = (arg ,), raw = True )
449+                 self .assertIn ('#. Translator comment' , data )
450+ 
435451
436452def  update_POT_snapshots ():
437453    for  input_file  in  DATA_DIR .glob ('*.py' ):
0 commit comments