mirror of
https://github.com/Hopiu/django-watson.git
synced 2026-04-02 13:40:23 +00:00
Fixed unicode errors in JSON tests under python 3.3
This commit is contained in:
parent
f7774282d3
commit
bfd3f87f6f
1 changed files with 4 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ from django.contrib.auth.models import User
|
|||
from django.http import HttpResponseNotFound, HttpResponseServerError
|
||||
from django import template
|
||||
from django.utils import simplejson as json
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
import watson
|
||||
from watson.registration import RegistrationError, get_backend, SearchEngine
|
||||
|
|
@ -602,7 +603,7 @@ class SiteSearchTest(SearchTestBase):
|
|||
# Test a search that should find everything.
|
||||
response = self.client.get("/simple/json/?q=title")
|
||||
self.assertEqual(response["Content-Type"], "application/json; charset=utf-8")
|
||||
results = set(result["title"] for result in json.loads(response.content)["results"])
|
||||
results = set(result["title"] for result in json.loads(force_text(response.content))["results"])
|
||||
self.assertEqual(len(results), 4)
|
||||
self.assertTrue("title model1 instance11" in results)
|
||||
self.assertTrue("title model1 instance12" in results)
|
||||
|
|
@ -645,7 +646,7 @@ class SiteSearchTest(SearchTestBase):
|
|||
# Test a search that should find everything.
|
||||
response = self.client.get("/custom/json/?fooo=title&page=last")
|
||||
self.assertEqual(response["Content-Type"], "application/json; charset=utf-8")
|
||||
results = set(result["title"] for result in json.loads(response.content)["results"])
|
||||
results = set(result["title"] for result in json.loads(force_text(response.content))["results"])
|
||||
self.assertEqual(len(results), 4)
|
||||
self.assertTrue("title model1 instance11" in results)
|
||||
self.assertTrue("title model1 instance12" in results)
|
||||
|
|
@ -657,4 +658,4 @@ class SiteSearchTest(SearchTestBase):
|
|||
|
||||
def tearDown(self):
|
||||
super(SiteSearchTest, self).tearDown()
|
||||
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
|
||||
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
|
||||
|
|
|
|||
Loading…
Reference in a new issue