File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -515,13 +515,11 @@ def test_bug691291(self):
515515 s1 = 'Hello\r \n world\r \n '
516516
517517 s = s1 .encode (self .encoding )
518- try :
519- with open (support .TESTFN , 'wb' ) as fp :
520- fp .write (s )
521- with codecs .open (support .TESTFN , 'U' , encoding = self .encoding ) as reader :
522- self .assertEqual (reader .read (), s1 )
523- finally :
524- support .unlink (support .TESTFN )
518+ self .addCleanup (support .unlink , support .TESTFN )
519+ with open (support .TESTFN , 'wb' ) as fp :
520+ fp .write (s )
521+ with codecs .open (support .TESTFN , 'U' , encoding = self .encoding ) as reader :
522+ self .assertEqual (reader .read (), s1 )
525523
526524class UTF16LETest (ReadTest ):
527525 encoding = "utf-16-le"
@@ -1628,6 +1626,7 @@ def test_seek0(self):
16281626 "utf-32" ,
16291627 "utf-32-le" ,
16301628 "utf-32-be" )
1629+ self .addCleanup (support .unlink , support .TESTFN )
16311630 for encoding in tests :
16321631 # Check if the BOM is written only once
16331632 with codecs .open (support .TESTFN , 'w+' , encoding = encoding ) as f :
You can’t perform that action at this time.
0 commit comments