diff --git a/simplejson/tests/test_tool.py b/simplejson/tests/test_tool.py index 6f3aec78211794f54b534cf03c1d8ee6abe93a06_c2ltcGxlanNvbi90ZXN0cy90ZXN0X3Rvb2wucHk=..15c5ffa638c9495f5420d88cc8092b3f0b23993c_c2ltcGxlanNvbi90ZXN0cy90ZXN0X3Rvb2wucHk= 100644 --- 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 index 6f3aec78211794f54b534cf03c1d8ee6abe93a06_c2ltcGxlanNvbi90b29sLnB5..15c5ffa638c9495f5420d88cc8092b3f0b23993c_c2ltcGxlanNvbi90b29sLnB5 100644 --- 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