# HG changeset patch # User Bob Ippolito <bob@redivi.com> # Date 1361489076 28800 # Thu Feb 21 15:24:36 2013 -0800 # Node ID 15c5ffa638c9495f5420d88cc8092b3f0b23993c # Parent 6f3aec78211794f54b534cf03c1d8ee6abe93a06 fix python 2.5 regression in tool and test_tool diff --git a/simplejson/tests/test_tool.py b/simplejson/tests/test_tool.py --- a/simplejson/tests/test_tool.py +++ b/simplejson/tests/test_tool.py @@ -1,3 +1,4 @@ +from __future__ import with_statement import os import sys import textwrap @@ -45,7 +46,7 @@ stderr=subprocess.PIPE, stdout=subprocess.PIPE) out, err = proc.communicate(data) - self.assertEqual(len(err), 0) + self.assertEqual(err, ''.encode()) self.assertEqual(proc.returncode, 0) return out @@ -68,7 +69,7 @@ infile.flush() # outfile will get overwritten by tool, so the delete # may not work on some platforms. Do it manually. - outfile = tempfile.NamedTemporaryFile(delete=0) + outfile = tempfile.NamedTemporaryFile() try: self.assertEqual( self.runTool(args=[infile.name, outfile.name]), @@ -77,4 +78,5 @@ self.assertEqual(f.read(), self.expect.encode()) finally: outfile.close() - os.unlink(outfile.name) + if os.path.exists(outfile.name): + os.unlink(outfile.name) diff --git a/simplejson/tool.py b/simplejson/tool.py --- a/simplejson/tool.py +++ b/simplejson/tool.py @@ -10,6 +10,7 @@ Expecting property name: line 1 column 2 (char 2) """ +from __future__ import with_statement import sys import simplejson as json