summaryrefslogtreecommitdiff
path: root/simplejson/tests
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2014-07-21 17:18:08 +0200
committerBob Ippolito <bob@redivi.com>2014-07-21 17:18:08 +0200
commit925cae72acd6a0d2a789cdc363736ed826f8ffa6 (patch)
tree201cfe69b7fcceef6e9f92887c9b431beb5ba970 /simplejson/tests
parent3eaa8d54dfed8cd64c9f439451f5514f45cd4dd4 (diff)
downloadsimplejson-925cae72acd6a0d2a789cdc363736ed826f8ffa6.tar.gz
generalize BOM stripping to any use of raw_decode
Diffstat (limited to 'simplejson/tests')
-rw-r--r--simplejson/tests/test_unicode.py15
-rw-r--r--simplejson/tests/utf-8-bom.json3
2 files changed, 7 insertions, 11 deletions
diff --git a/simplejson/tests/test_unicode.py b/simplejson/tests/test_unicode.py
index 60492f7..3b37f65 100644
--- a/simplejson/tests/test_unicode.py
+++ b/simplejson/tests/test_unicode.py
@@ -1,9 +1,9 @@
import sys
-import os.path
+import codecs
from unittest import TestCase
import simplejson as json
-from simplejson.compat import unichr, text_type, b, u
+from simplejson.compat import unichr, text_type, b, u, BytesIO
class TestUnicode(TestCase):
def test_encoding1(self):
@@ -146,9 +146,8 @@ class TestUnicode(TestCase):
'"' + c + '"')
def test_strip_bom(self):
- thisdir = os.path.dirname(__file__)
- json_file = os.path.join(thisdir, "utf-8-bom.json")
- doc_ascii = {
- u"content": u"\u3053\u3093\u306b\u3061\u308f"
- }
- self.assertEqual(json.load(open(json_file)), doc_ascii)
+ content = u"\u3053\u3093\u306b\u3061\u308f"
+ json_doc = codecs.BOM_UTF8 + b(json.dumps(content))
+ self.assertEqual(json.load(BytesIO(json_doc)), content)
+ for doc in json_doc, json_doc.decode('utf8'):
+ self.assertEqual(json.loads(doc), content)
diff --git a/simplejson/tests/utf-8-bom.json b/simplejson/tests/utf-8-bom.json
deleted file mode 100644
index 1791beb..0000000
--- a/simplejson/tests/utf-8-bom.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "content": "こんにちわ"
-}