@@ -246,19 +246,14 @@ def setUp(self):
246
246
self .deleted_file = os_helper .TESTFN + '.1'
247
247
self .modified_file = os_helper .TESTFN + '.2'
248
248
self .unchanged_file = os_helper .TESTFN + '.3'
249
- self .addCleanup (os_helper .unlink , self .deleted_file )
250
- self .addCleanup (os_helper .unlink , self .modified_file )
251
- self .addCleanup (os_helper .unlink , self .unchanged_file )
252
- with open (self .deleted_file , 'w' , encoding = 'utf-8' ) as source :
253
- source .write ('print("will be deleted")' )
254
- with open (self .modified_file , 'w' , encoding = 'utf-8' ) as source :
255
- source .write ('print("will be modified")' )
256
- with open (self .unchanged_file , 'w' , encoding = 'utf-8' ) as source :
257
- source .write ('print("unchange")' )
258
249
259
- linecache .getlines (self .deleted_file )
260
- linecache .getlines (self .modified_file )
261
- linecache .getlines (self .unchanged_file )
250
+ for fname in (self .deleted_file ,
251
+ self .modified_file ,
252
+ self .unchanged_file ):
253
+ self .addCleanup (os_helper .unlink , fname )
254
+ with open (fname , 'w' , encoding = 'utf-8' ) as source :
255
+ source .write (f'print("I am { fname } ")' )
256
+ linecache .getlines (fname )
262
257
263
258
os .remove (self .deleted_file )
264
259
with open (self .modified_file , 'w' , encoding = 'utf-8' ) as source :
0 commit comments