summaryrefslogtreecommitdiff
path: root/tests/osinfo.py
diff options
context:
space:
mode:
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 acbec23..a123123 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 ...'