fixed unclosed file error

This commit is contained in:
cis-kuldeep 2021-07-09 15:49:11 +05:30
parent 71b5c87f75
commit 9bf5c84c41
No known key found for this signature in database
GPG Key ID: 67B47D8A06FA45E4

View File

@ -84,7 +84,8 @@ class TestProcessProto(unittest.TestCase):
def _get_readline(cls, pfile):
pfile = os.path.join(cls.home, pfile)
try:
return open(pfile, 'rb').readline().strip()
with open(pfile, 'rb') as p:
return p.readline().strip()
except (OSError, IOError):
pass