tests: do not leak open file
This commit is contained in:
parent
f1a5ca64fd
commit
241f1d1d3b
@ -71,7 +71,8 @@ def pcidev_class(dev_xmldesc):
|
|||||||
sysfs_path = dev_xmldesc.findtext('path')
|
sysfs_path = dev_xmldesc.findtext('path')
|
||||||
assert sysfs_path
|
assert sysfs_path
|
||||||
try:
|
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:
|
except OSError:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user