@@ -607,30 +607,26 @@ def test_finddoc(self):
607607 'doc\0 string\n \n second\0 line\n third\0 line\0 ' ),
608608 # first line is lstrip()-ped. other lines are kept when no margin.[w:
609609 (' ' , '' ),
610+ # compiler.cleandoc() doesn't strip leading/trailing newlines
611+ # to keep maximum backward compatibility.
612+ # inspect.cleandoc() removes them.
613+ ('\n \n \n first paragraph\n \n second paragraph\n \n ' ,
614+ '\n \n \n first paragraph\n \n second paragraph\n \n ' ),
615+ (' \n \n \n ' , '\n \n \n ' ),
610616 ]
611617
612618 def test_cleandoc (self ):
613619 func = inspect .cleandoc
614- testdata = self .cleandoc_testdata + [
615- # leading and trailing empty lines should be removed
616- ('\n \n \n first paragraph\n \n second paragraph\n \n ' ,
617- 'first paragraph\n \n second paragraph' ),
618- (' \n \n \n ' , ' \n \n ' ),
619- ]
620- for i , (input , expected ) in enumerate (testdata ):
620+ for i , (input , expected ) in enumerate (self .cleandoc_testdata ):
621+ # only inspect.cleandoc() strip \n
622+ expected = expected .strip ('\n ' )
621623 with self .subTest (i = i ):
622624 self .assertEqual (func (input ), expected )
623625
624626 @cpython_only
625627 def test_c_cleandoc (self ):
626628 import _testinternalcapi
627629 func = _testinternalcapi .compiler_cleandoc
628- testdata = self .cleandoc_testdata + [
629- # leading and trailing empty lines are not removed
630- ('\n \n \n first paragraph\n \n second paragraph\n \n ' ,
631- '\n \n \n first paragraph\n \n second paragraph\n \n ' ),
632- (' \n \n \n ' , '\n \n \n ' ),
633- ]
634630 for i , (input , expected ) in enumerate (self .cleandoc_testdata ):
635631 with self .subTest (i = i ):
636632 self .assertEqual (func (input ), expected )
0 commit comments