Просмотр исходного кода

Make newly added threads code Python 3.5 compatible

NeKit 8 лет назад
Родитель
Сommit
eff84626a4

+ 1 - 1
misago/threads/tests/test_threads_api.py

@@ -70,7 +70,7 @@ class ThreadRetrieveApiTests(ThreadsApiTestCase):
             response = self.client.get(link)
             self.assertEqual(response.status_code, 200)
 
-            response_json = json.loads(response.content)
+            response_json = json.loads(smart_str(response.content))
             self.assertEqual(response_json['id'], self.thread.pk)
             self.assertEqual(response_json['title'], self.thread.title)
 

+ 3 - 2
misago/threads/tests/test_threads_merge_api.py

@@ -2,6 +2,7 @@ import json
 
 from django.core.urlresolvers import reverse
 from django.utils.encoding import smart_str
+from django.utils.six.moves import range
 
 from misago.acl import add_acl
 from misago.acl.testutils import override_acl
@@ -139,7 +140,7 @@ class ThreadsMergeApiTests(ThreadsApiTestCase):
     def test_merge_too_many_threads(self):
         """api rejects too many threads to merge"""
         threads = []
-        for i in xrange(MERGE_LIMIT + 1):
+        for i in range(MERGE_LIMIT + 1):
             threads.append(testutils.post_thread(category=self.category).pk)
 
         self.override_acl({
@@ -154,7 +155,7 @@ class ThreadsMergeApiTests(ThreadsApiTestCase):
         }), content_type="application/json")
         self.assertEqual(response.status_code, 403)
 
-        response_json = json.loads(response.content)
+        response_json = json.loads(smart_str(response.content))
         self.assertEqual(response_json, {
             'detail': "No more than %s threads can be merged at single time." % MERGE_LIMIT
         })

+ 3 - 2
misago/threads/tests/test_typestree.py

@@ -1,4 +1,5 @@
 from django.test import TestCase
+from django.utils import six
 
 from misago.categories.models import Category
 
@@ -75,7 +76,7 @@ class TreesMapTests(TestCase):
             trees_map.get_type_for_tree_id(tree_id + 1000)
             self.fail("invalid tree id should cause KeyError being raised")
         except KeyError as e:
-            self.assertIn("tree id has no type defined", unicode(e), "invalid exception message as given")
+            self.assertIn("tree id has no type defined", six.text_type(e), "invalid exception message as given")
 
     def test_get_tree_id_for_root(self):
         """TreesMap().get_tree_id_for_root() returns tree id for valid type name"""
@@ -91,4 +92,4 @@ class TreesMapTests(TestCase):
             trees_map.get_tree_id_for_root('hurr_durr')
             self.fail("invalid root name should cause KeyError being raised")
         except KeyError as e:
-            self.assertIn('"hurr_durr" root has no tree defined', unicode(e), "invalid exception message as given")
+            self.assertIn('"hurr_durr" root has no tree defined', six.text_type(e), "invalid exception message as given")

+ 1 - 1
misago/threads/views/goto.py

@@ -41,7 +41,7 @@ class GotoView(View):
             return 1 # no chance for post to be on other page than only page
 
         # compute total count of thread pages
-        thread_pages = thread_len / settings.MISAGO_POSTS_PER_PAGE
+        thread_pages = thread_len // settings.MISAGO_POSTS_PER_PAGE
         thread_tail = thread_len - thread_pages * settings.MISAGO_POSTS_PER_PAGE
         if thread_tail > settings.MISAGO_POSTS_TAIL:
             thread_pages += 1