aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-11-30 23:45:50 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-11-30 23:46:33 +0100
commita6d7c65d3f731bdcc75c86362b0bb43f8895cd32 (patch)
tree4d0db359acc24e48e6f0a5a62d805e9fdf69b0d6
parentfa8858e6b70dfabf026ef3018d702260c2405137 (diff)
downloadjson_diff-a6d7c65d3f731bdcc75c86362b0bb43f8895cd32.tar.gz
Make tests working independently of the locale set on the system.1.2.1
-rwxr-xr-xjson_diff.py4
-rw-r--r--test_json_diff.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/json_diff.py b/json_diff.py
index cc8bfa7..e07d598 100755
--- a/json_diff.py
+++ b/json_diff.py
@@ -32,7 +32,7 @@ import logging
from optparse import OptionParser
__author__ = "Matěj Cepl"
-__version__ = "1.2.0"
+__version__ = "1.2.1"
import locale
@@ -358,7 +358,7 @@ def main(sys_args):
print(unicode(HTMLFormatter(diff_res)).encode("utf-8"))
else:
outs = json.dumps(diff_res, indent=4, ensure_ascii=False)
- print(outs.encode(locale.getpreferredencoding()))
+ print(outs.encode(locale.getpreferredencoding(do_setlocale=False)))
if len(diff_res) > 0:
return 1
diff --git a/test_json_diff.py b/test_json_diff.py
index 95296e0..7fb713a 100644
--- a/test_json_diff.py
+++ b/test_json_diff.py
@@ -4,6 +4,7 @@ PyUnit unit tests
"""
import unittest
import sys
+import locale
try:
import json
except ImportError:
@@ -195,11 +196,14 @@ class TestMainArgsMgmt(unittest.TestCase):
def test_args_run_different(self):
save_stdout = StringIO()
sys.stdout = save_stdout
+ cur_loc = locale.getlocale()
+ locale.setlocale(locale.LC_ALL, ("cs_CZ", "utf-8"))
res = json_diff.main(["./test_json_diff.py",
"test/old.json", "test/new.json"])
sys.stdout = sys.__stdout__
+ locale.setlocale(locale.LC_ALL, cur_loc)
self.assertEquals(res, 1, "testing -h usage message")
if __name__ == "__main__":