Serhiy Storchaka added the comment:
Tests added. They fail until issue16333 will be resolved.
----------
Added file: http://bugs.python.org/file28115/json_tool_tests.patch
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16549>
_______________________________________
diff -r aac6b313ef5f Lib/test/json_tests/test_tool.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/test/json_tests/test_tool.py Sun Nov 25 17:03:12 2012 +0200
@@ -0,0 +1,53 @@
+import os
+import textwrap
+import unittest
+from test import support
+from test.script_helper import assert_python_ok
+from test.support import TESTFN
+
+class TestTool(unittest.TestCase):
+ data = """
+
+ [["blorpie"],[ "whoops" ] , [
+ ],\t"d-shtaeou",\r"d-nthiouh",
+ "i-vhbjkhnth", {"nifty":87}, {"morefield" :\tfalse,"field"
+ :"yes"} ]
+ """
+
+ expect = textwrap.dedent("""\
+ [
+ [
+ "blorpie"
+ ],
+ [
+ "whoops"
+ ],
+ [],
+ "d-shtaeou",
+ "d-nthiouh",
+ "i-vhbjkhnth",
+ {
+ "nifty": 87
+ },
+ {
+ "field": "yes",
+ "morefield": false
+ }
+ ]
+ """)
+
+ def test_tool(self):
+ infile = support.TESTFN
+ with open(infile, "w") as fp:
+ self.addCleanup(os.remove, infile)
+ fp.write(self.data)
+ rc, out, err = assert_python_ok('-m', 'json.tool', infile)
+ self.assertEqual(out, self.expect.encode())
+ self.assertEqual(err, b'')
+ outfile = support.TESTFN + '.out'
+ rc, out, err = assert_python_ok('-m', 'json.tool', infile, outfile)
+ self.addCleanup(os.remove, outfile)
+ with open(outfile, "r") as fp:
+ self.assertEqual(fp.read(), self.expect)
+ self.assertEqual(out, b'')
+ self.assertEqual(err, b'')
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com