Merge ~jslarraz/qa-regression-testing:close-version-signature-fd into qa-regression-testing:master

Proposed by Jorge Sancho Larraz
Status: Merged
Merged at revision: 104077ff12192981823353ad71d7cbf0229b1f3b
Proposed branch: ~jslarraz/qa-regression-testing:close-version-signature-fd
Merge into: qa-regression-testing:master
Diff against target: 14 lines (+2/-1)
1 file modified
scripts/testlib.py (+2/-1)
Reviewer Review Type Date Requested Status
Steve Beattie Approve
Review via email: mp+459451@code.launchpad.net

Commit message

testlib: close /proc/version_signature fd

Description of the change

Currently testlib.py doesn't close the file descriptor for /proc/version_signature after reading the information to determine the ubuntu version. That produces the following warning in qrt report:

/root/qrt-test-amanda/testlib.py:1051: ResourceWarning: unclosed file <_io.TextIOWrapper name='/proc/version_signature' mode='r' encoding='UTF-8'>
  self.kernel_version_signature = open(versig).read().strip()

To post a comment you must log in.
Revision history for this message
Steve Beattie (sbeattie) wrote :

Nice catch, thanks! Merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/testlib.py b/scripts/testlib.py
2index 9191a4a..47494e3 100644
3--- a/scripts/testlib.py
4+++ b/scripts/testlib.py
5@@ -1120,7 +1120,8 @@ class TestlibManager(object):
6 versig = '/proc/version_signature'
7 if os.path.exists(versig):
8 self.kernel_is_ubuntu = True
9- self.kernel_version_signature = open(versig).read().strip()
10+ with open(versig) as fd:
11+ self.kernel_version_signature = fd.read().strip()
12 self.kernel_version_ubuntu = self.kernel_version
13 elif os.path.exists('/usr/bin/dpkg'):
14 # this can easily be inaccurate but is only an issue for Dapper

Subscribers

People subscribed via source and target branches