diff options
author | Matěj Cepl <mcepl@redhat.com> | 2012-04-24 01:43:03 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2012-04-24 01:43:03 +0200 |
commit | 34c29fee135803154c6bb494d908b98067f028e2 (patch) | |
tree | b6aa93a0d0142c17eb6e61b5c0af386419f2d9ee /test/test_json_diff.py | |
parent | 2e1ad9c3446ed37ce40a91bbb6db4c9e39fe0338 (diff) | |
download | json_diff-34c29fee135803154c6bb494d908b98067f028e2.tar.gz |
Added -o parameter for output to the specified file.1.3.0
Diffstat (limited to 'test/test_json_diff.py')
-rw-r--r-- | test/test_json_diff.py | 23 |
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() |