Repository: learningequality/morango (language: python)

Issue:
Drop Python 2.7 support
Kolibri has dropped Python 2.7 support in its develop branch, so Morango can do the same.

All testing and library support for Python 2.7 can be removed, and any special casing added in the code base for Python 2.7 can be removed.


Discussion / hints:

Fix patch:
diff --git a/morango/models/fields/crypto.py b/morango/models/fields/crypto.py
index be81dd3a..13ac2d2e 100644
--- a/morango/models/fields/crypto.py
+++ b/morango/models/fields/crypto.py
@@ -6,7 +6,6 @@
 """
 import hashlib
 import re
-import sys
 
 import rsa as PYRSA
 from django.db import models
@@ -41,10 +40,8 @@
 except ImportError:
     CRYPTOGRAPHY_EXISTS = False
 
-if sys.version_info[0] < 3:
-    from base64 import encodestring as b64encode, decodestring as b64decode
-else:
-    from base64 import encodebytes as b64encode, decodebytes as b64decode
+
+from base64 import encodebytes as b64encode, decodebytes as b64decode
 
 
 PKCS8_HEADER = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A"


Test patch:
diff --git a/tests/testapp/tests/test_api.py b/tests/testapp/tests/test_api.py
index 01d7399b..2b1367d5 100644
--- a/tests/testapp/tests/test_api.py
+++ b/tests/testapp/tests/test_api.py
@@ -1,6 +1,6 @@
 import json
-import sys
 import uuid
+from base64 import encodebytes as b64encode
 
 from django.db import connection
 from django.test.utils import CaptureQueriesContext
@@ -10,7 +10,7 @@
 from django.utils import timezone
 from django.utils.functional import SimpleLazyObject
 from facility_profile.models import MyUser
-from rest_framework.test import APITestCase as BaseTestCase
+from rest_framework.test import APITestCase
 
 from .compat import EnvironmentVarGuard
 from morango.api.serializers import BufferSerializer
@@ -33,21 +33,6 @@
 from morango.sync.syncsession import compress_string
 from morango.sync.utils import validate_and_create_buffer_data
 
-if sys.version_info >= (3,):
-    from base64 import encodebytes as b64encode
-
-    # A weird hack because of http://bugs.python.org/issue17866
-    class APITestCase(BaseTestCase):
-        def assertItemsEqual(self, *args, **kwargs):
-            self.assertCountEqual(*args, **kwargs)
-
-
-else:
-    from base64 import encodestring as b64encode
-
-    class APITestCase(BaseTestCase):
-        pass
-
 
 class CertificateTestCaseMixin(object):
     def setUp(self):