From a7039db994cd602ed23ae8b098871cf12f966fe9 Mon Sep 17 00:00:00 2001 From: Bob Ippolito Date: Thu, 21 Feb 2013 15:24:36 -0800 Subject: fix python 2.5 regression in tool and test_tool --- simplejson/tests/test_tool.py | 8 +++++--- simplejson/tool.py | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/simplejson/tests/test_tool.py b/simplejson/tests/test_tool.py index f39f0ee..af3c4ba 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 @@ class TestTool(unittest.TestCase): 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 @@ class TestTool(unittest.TestCase): 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 @@ class TestTool(unittest.TestCase): 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 35627db..062e8e2 100644 --- a/simplejson/tool.py +++ b/simplejson/tool.py @@ -10,6 +10,7 @@ Usage:: Expecting property name: line 1 column 2 (char 2) """ +from __future__ import with_statement import sys import simplejson as json -- cgit v1.2.1