use "with" with open()

This commit is contained in:
Thomas Waldmann 2015-03-17 23:09:14 +01:00
parent fec5572836
commit dee9869a03
1 changed files with 3 additions and 4 deletions

View File

@ -262,10 +262,9 @@ class ArchiverTestCase(ArchiverTestCaseBase):
self.attic('extract', '--dry-run', self.repository_location + '::test') self.attic('extract', '--dry-run', self.repository_location + '::test')
self.attic('check', self.repository_location) self.attic('check', self.repository_location)
name = sorted(os.listdir(os.path.join(self.tmpdir, 'repository', 'data', '0')), reverse=True)[0] name = sorted(os.listdir(os.path.join(self.tmpdir, 'repository', 'data', '0')), reverse=True)[0]
fd = open(os.path.join(self.tmpdir, 'repository', 'data', '0', name), 'r+') with open(os.path.join(self.tmpdir, 'repository', 'data', '0', name), 'r+') as fd:
fd.seek(100) fd.seek(100)
fd.write('XXXX') fd.write('XXXX')
fd.close()
self.attic('check', self.repository_location, exit_code=1) self.attic('check', self.repository_location, exit_code=1)
def test_readonly_repository(self): def test_readonly_repository(self):