aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_json_diff.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test_json_diff.py b/test/test_json_diff.py
index cb2e878..d7c16e3 100644
--- a/test/test_json_diff.py
+++ b/test/test_json_diff.py
@@ -2,8 +2,10 @@
"""
PyUnit unit tests
"""
+from __future__ import print_function
import unittest
import sys
+import tempfile
import locale
try:
import json
@@ -215,6 +217,27 @@ class TestMainArgsMgmt(unittest.TestCase):
"\n\nexpected = %d\n\nobserved = %d" %
(1, res))
+ def test_args_run_output(self):
+ save_stdout = tempfile.NamedTemporaryFile(prefix="json_diff_")
+ cur_loc = locale.getlocale()
+ locale.setlocale(locale.LC_ALL, "cs_CZ.utf8")
+
+ res = json_diff.main(["./test_json_diff.py",
+ "-o", save_stdout.name,
+ "test/old.json", "test/new.json"])
+
+ expected_file = open("test/diff.json")
+ expected = expected_file.read()
+
+ save_stdout.seek(0)
+ observed = save_stdout.read()
+ save_stdout.close()
+
+ locale.setlocale(locale.LC_ALL, cur_loc)
+ self.assertEqual(expected, observed, "non-stdout output file" +
+ "\n\nexpected = %s\n\nobserved = %s" %
+ (expected, observed))
+
add_tests_from_class = unittest.TestLoader().loadTestsFromTestCase
suite = unittest.TestSuite()