#16549: Add tests for json.tools. Initial patch by Berker Peksag and Serhiy Storchaka.

This commit is contained in:
Ezio Melotti 2012-11-29 02:14:52 +02:00
parent 67473263a3
commit d8feba904c
4 changed files with 81 additions and 6 deletions

View file

@ -25,12 +25,14 @@ def main():
outfile = open(sys.argv[2], 'wb')
else:
raise SystemExit(sys.argv[0] + " [infile [outfile]]")
try:
obj = json.load(infile)
except ValueError, e:
raise SystemExit(e)
json.dump(obj, outfile, sort_keys=True, indent=4)
outfile.write('\n')
with infile:
try:
obj = json.load(infile)
except ValueError, e:
raise SystemExit(e)
with outfile:
json.dump(obj, outfile, sort_keys=True, indent=4)
outfile.write('\n')
if __name__ == '__main__':