summaryrefslogtreecommitdiff
path: root/tests/osinfo.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-10-20 07:58:57 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-10-20 07:58:57 -0400
commit6b6a4488adc12d390c5e0c8f13829dd9bf125309 (patch)
tree4eeeeb857c02023fd46d610612f600d533105afb /tests/osinfo.py
parent2e5688eedd1576e9b100386c0a9ae30828123f73 (diff)
downloadpython-coveragepy-git-6b6a4488adc12d390c5e0c8f13829dd9bf125309.tar.gz
with statements: no more finally close
--HG-- branch : 4.0
Diffstat (limited to 'tests/osinfo.py')
-rw-r--r--tests/osinfo.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/tests/osinfo.py b/tests/osinfo.py
index acbec231..a123123c 100644
--- a/tests/osinfo.py
+++ b/tests/osinfo.py
@@ -44,11 +44,8 @@ elif sys.platform == 'linux2':
"""Read the /proc/PID/status file to find memory use."""
try:
# get pseudo file /proc/<pid>/status
- t = open('/proc/%d/status' % os.getpid())
- try:
+ with open('/proc/%d/status' % os.getpid()) as t:
v = t.read()
- finally:
- t.close()
except IOError:
return 0 # non-Linux?
# get VmKey line e.g. 'VmRSS: 9999 kB\n ...'