summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@debian.org>2019-03-13 14:12:24 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2019-03-13 14:12:24 +0100
commit3762d0f8d6206bd70b16647d0f2c11172ef958db (patch)
tree6744774fc985476a3d227d01df5adb3dc3410cd4
parent6c71973462f0c1768f99660a112ba14f3714e082 (diff)
downloadpsutil-3762d0f8d6206bd70b16647d0f2c11172ef958db.tar.gz
Make tests invariant to LANG setting (#1462)
When LANG is set to a non English locale (e.g. de_DE.UTF-8), free and vmstat will output the text translated and cause the test cases to fail. Therefore set LANG=C.UTF-8 when calling free or vmstat to always get the English output.
-rwxr-xr-xpsutil/tests/test_linux.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index eb3e560d..6e260b99 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -96,7 +96,7 @@ def free_swap():
"""Parse 'free' cmd and return swap memory's s total, used and free
values.
"""
- out = sh('free -b')
+ out = sh('free -b', env={"LANG": "C.UTF-8"})
lines = out.split('\n')
for line in lines:
if line.startswith('Swap'):
@@ -115,7 +115,7 @@ def free_physmem():
# and 'cached' memory which may have different positions so we
# do not return them.
# https://github.com/giampaolo/psutil/issues/538#issuecomment-57059946
- out = sh('free -b')
+ out = sh('free -b', env={"LANG": "C.UTF-8"})
lines = out.split('\n')
for line in lines:
if line.startswith('Mem'):
@@ -129,7 +129,7 @@ def free_physmem():
def vmstat(stat):
- out = sh("vmstat -s")
+ out = sh("vmstat -s", env={"LANG": "C.UTF-8"})
for line in out.split("\n"):
line = line.strip()
if stat in line: