From 86c7b9f809f01baefe6882b426ee61e610b0b7b2 Mon Sep 17 00:00:00 2001
From: aarif <mraarif@outlook.com>
Date: Tue, 1 Oct 2019 13:46:12 +0500
Subject: [PATCH] updated the division operation to make the output compatible
 in python 2 and python 3

changes made to fix quality errors

changes made to fix issues on BOM-587

minor changes made to fix quality issues

minor changes

removed unused pylint supression
---
 .../core/djangoapps/contentserver/middleware.py   |  2 +-
 .../contentserver/test/test_contentserver.py      | 15 +++++----------
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/openedx/core/djangoapps/contentserver/middleware.py b/openedx/core/djangoapps/contentserver/middleware.py
index 5dec3f00063..88f392462da 100644
--- a/openedx/core/djangoapps/contentserver/middleware.py
+++ b/openedx/core/djangoapps/contentserver/middleware.py
@@ -156,7 +156,7 @@ class StaticContentServer(object):
                         if 0 <= first <= last < content.length:
                             # If the byte range is satisfiable
                             response = HttpResponse(content.stream_data_in_range(first, last))
-                            response['Content-Range'] = b'bytes {first}-{last}/{length}'.format(
+                            response['Content-Range'] = u'bytes {first}-{last}/{length}'.format(
                                 first=first, last=last, length=content.length
                             )
                             response['Content-Length'] = str(last - first + 1)
diff --git a/openedx/core/djangoapps/contentserver/test/test_contentserver.py b/openedx/core/djangoapps/contentserver/test/test_contentserver.py
index 5c111bbdc97..3d892ec6684 100644
--- a/openedx/core/djangoapps/contentserver/test/test_contentserver.py
+++ b/openedx/core/djangoapps/contentserver/test/test_contentserver.py
@@ -218,13 +218,8 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
         resp = self.client.get(self.url_unlocked, HTTP_RANGE='bytes=0-')
 
         self.assertEqual(resp.status_code, 206)  # HTTP_206_PARTIAL_CONTENT
-        self.assertEqual(
-            resp['Content-Range'],
-            b'bytes {first}-{last}/{length}'.format(
-                first=0, last=self.length_unlocked - 1,
-                length=self.length_unlocked
-            )
-        )
+        self.assertEqual(resp['Content-Range'], u'bytes {first}-{last}/{length}'
+                         .format(first=0, last=self.length_unlocked - 1, length=self.length_unlocked))
         self.assertEqual(resp['Content-Length'], str(self.length_unlocked))
 
     def test_range_request_partial_file(self):
@@ -233,13 +228,13 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
         outputs partial content status code and valid Content-Range and Content-Length.
         first_byte and last_byte are chosen to be simple but non trivial values.
         """
-        first_byte = self.length_unlocked / 4
-        last_byte = self.length_unlocked / 2
+        first_byte = self.length_unlocked // 4
+        last_byte = self.length_unlocked // 2
         resp = self.client.get(self.url_unlocked, HTTP_RANGE='bytes={first}-{last}'.format(
             first=first_byte, last=last_byte))
 
         self.assertEqual(resp.status_code, 206)  # HTTP_206_PARTIAL_CONTENT
-        self.assertEqual(resp['Content-Range'], b'bytes {first}-{last}/{length}'.format(
+        self.assertEqual(resp['Content-Range'], u'bytes {first}-{last}/{length}'.format(
             first=first_byte, last=last_byte, length=self.length_unlocked))
         self.assertEqual(resp['Content-Length'], str(last_byte - first_byte + 1))
 
-- 
GitLab