tests: do not leak open file

This commit is contained in:
Marek Marczykowski-Górecki 2018-01-15 15:57:30 +01:00
parent f1a5ca64fd
commit 241f1d1d3b
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -71,7 +71,8 @@ def pcidev_class(dev_xmldesc):
sysfs_path = dev_xmldesc.findtext('path')
assert sysfs_path
try:
class_id = open(sysfs_path + '/class').read().strip()
with open(sysfs_path + '/class') as f_class:
class_id = f_class.read().strip()
except OSError:
return "Unknown"