summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2013-02-21 15:24:36 -0800
committerBob Ippolito <bob@redivi.com>2013-02-21 15:34:53 -0800
commita7039db994cd602ed23ae8b098871cf12f966fe9 (patch)
treec6fea7c05f51347910bfa471c9e9c187fa9c8e2f
parent68aea11176fc7e3f376482dbddccd252836c1b85 (diff)
downloadsimplejson-a7039db994cd602ed23ae8b098871cf12f966fe9.tar.gz
fix python 2.5 regression in tool and test_toolpy-backports
-rw-r--r--simplejson/tests/test_tool.py8
-rw-r--r--simplejson/tool.py1
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