def test_args_help(self): save_stdout = StringIO() sys.stdout = save_stdout try: json_diff.main(["./test_json_diff.py", "-h"]) except SystemExit: save_stdout.seek(0) sys.stdout = sys.__stdout__ expected = "usage:" observed = save_stdout.read().lower() self.assertEquals( observed[:len(expected)], expected, "testing -h usage message" + "\n\nexpected = %s\n\nobserved = %s" % (expected, observed))
def test_args_help(self): save_stdout = StringIO() sys.stdout = save_stdout try: json_diff.main(["./test_json_diff.py", "-h"]) except SystemExit: save_stdout.seek(0) sys.stdout = sys.__stdout__ expected = "usage:" observed = save_stdout.read().lower() self.assertEquals(observed[:len(expected)], expected, "testing -h usage message" + "\n\nexpected = %s\n\nobserved = %s" % (expected, observed))
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") 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))
def test_args_run_different(self): save_stdout = StringIO() sys.stdout = save_stdout cur_loc = locale.getlocale() locale.setlocale(locale.LC_ALL, "cs_CZ.utf8") 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.assertEqual(res, 1, "comparing different files" + "\n\nexpected = %d\n\nobserved = %d" % (1, res))
def test_args_run_different(self): save_stdout = StringIO() sys.stdout = save_stdout cur_loc = locale.getlocale() locale.setlocale(locale.LC_ALL, "cs_CZ.utf8") 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.assertEqual( res, 1, "comparing different files" + "\n\nexpected = %d\n\nobserved = %d" % (1, res))