Skip to content

Commit

Permalink
Use context managers for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Apr 16, 2015
1 parent 1902c01 commit e90680f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions OpenSSL/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,16 +1217,14 @@ def test_add_extra_chain_cert(self):
for cert, name in [(cacert, 'ca.pem'),
(icert, 'i.pem'),
(scert, 's.pem')]:
fObj = open(join(self.tmpdir, name), 'w')
fObj.write(dump_certificate(FILETYPE_PEM, cert).decode('ascii'))
fObj.close()
with open(join(self.tmpdir, name), 'w') as f:
f.write(dump_certificate(FILETYPE_PEM, cert).decode('ascii'))

for key, name in [(cakey, 'ca.key'),
(ikey, 'i.key'),
(skey, 's.key')]:
fObj = open(join(self.tmpdir, name), 'w')
fObj.write(dump_privatekey(FILETYPE_PEM, key).decode('ascii'))
fObj.close()
with open(join(self.tmpdir, name), 'w') as f:
f.write(dump_privatekey(FILETYPE_PEM, key).decode('ascii'))

# Create the server context
serverContext = Context(TLSv1_METHOD)
Expand Down

0 comments on commit e90680f

Please sign in to comment.