From 842c8cfa80721cd80a2b2fe57410a44537569b72 Mon Sep 17 00:00:00 2001 From: usamasadiq Date: Wed, 9 Dec 2020 14:50:32 +0500 Subject: [PATCH 1/2] Update tox to remove python35 --- requirements/edx/django31.txt | 1 + tox.ini | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 requirements/edx/django31.txt diff --git a/requirements/edx/django31.txt b/requirements/edx/django31.txt new file mode 100644 index 0000000000..36acb6babf --- /dev/null +++ b/requirements/edx/django31.txt @@ -0,0 +1 @@ +Django>=3.1,<3.2 diff --git a/tox.ini b/tox.ini index 06e8fbca9d..5075783ee3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{35}-django{22},py{38}-django{22,30} +envlist = py{38}-django{22,30,31} # This is needed to prevent the lms, cms, and openedx packages inside the "Open # edX" package (defined in setup.py) from getting installed into site-packages @@ -70,6 +70,7 @@ passenv = deps = django22: -r requirements/edx/django.txt django30: -r requirements/edx/django30.txt + django31: -r requirements/edx/django31.txt -r requirements/edx/testing.txt whitelist_externals = /bin/bash From dbfec8ee3ce2d00edcedf39bf3b29e5d4dd060f2 Mon Sep 17 00:00:00 2001 From: usamasadiq Date: Mon, 1 Feb 2021 16:30:47 +0500 Subject: [PATCH 2/2] Remove nonrequired conditions --- .../xmodule/xmodule/modulestore/__init__.py | 8 +-- common/test/utils.py | 10 --- .../django_comment_client/tests/test_utils.py | 68 ------------------- 3 files changed, 1 insertion(+), 85 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 27aa5573eb..74b52b1196 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -32,12 +32,6 @@ from xmodule.errortracker import make_error_tracker from .exceptions import InsufficientSpecificationError, InvalidLocationError -# The name of the type for patterns in re changed in Python 3.7. -try: - Pattern = re._pattern_type # pylint: disable=protected-access -except AttributeError: - Pattern = re.Pattern # pylint: disable=no-member - log = logging.getLogger('edx.modulestore') new_contract('CourseKey', CourseKey) @@ -905,7 +899,7 @@ class ModuleStoreRead(six.with_metaclass(ABCMeta, ModuleStoreAssetBase)): """ if isinstance(target, list): return any(self._value_matches(ele, criteria) for ele in target) - elif isinstance(criteria, Pattern): + elif isinstance(criteria, re.Pattern): return criteria.search(target) is not None elif callable(criteria): return criteria(target) diff --git a/common/test/utils.py b/common/test/utils.py index 8b78ba98ed..cfb031b35a 100644 --- a/common/test/utils.py +++ b/common/test/utils.py @@ -158,13 +158,3 @@ def normalize_repr(func): between worker processes. """ return reprwrapper(func) - - -# Decorator for skipping tests that are not ready to be run with Python 3.x. -# While we expect many tests to fail with Python 3.x as we transition, this -# is specifically for tests that rely on external or large scale fixes. It can -# be added to individual tests or test classes. -py2_only = pytest.mark.skipif( - sys.version_info > (3, 0), - reason="This test can only be run with Python 2.7, currently" -) diff --git a/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py b/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py index 11aa4c7696..a667724db2 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py @@ -951,10 +951,6 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase): } ) - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="Python 3.7 sorted dict insertion is considered" - ) def test_sort_intermediates(self): self.create_discussion("Chapter B", "Discussion 2") self.create_discussion("Chapter C", "Discussion") @@ -1015,70 +1011,6 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase): } ) - @pytest.mark.skipif( - sys.version_info >= (3, 7), - reason="Python 3.7 sorted dict insertion is not considered" - ) - def test_sort_intermediates(self): - self.create_discussion("Chapter B", "Discussion 2") - self.create_discussion("Chapter C", "Discussion") - self.create_discussion("Chapter A", "Discussion 1") - self.create_discussion("Chapter B", "Discussion 1") - self.create_discussion("Chapter A", "Discussion 2") - - self.assert_category_map_equals( - { - "entries": {}, - "subcategories": { - "Chapter A": { - "entries": { - "Discussion 1": { - "id": "discussion3", - "sort_key": None, - "is_divided": False, - }, - "Discussion 2": { - "id": "discussion5", - "sort_key": None, - "is_divided": False, - } - }, - "subcategories": {}, - "children": [("Discussion 1", TYPE_ENTRY), ("Discussion 2", TYPE_ENTRY)] - }, - "Chapter B": { - "entries": { - "Discussion 1": { - "id": "discussion4", - "sort_key": None, - "is_divided": False, - }, - "Discussion 2": { - "id": "discussion1", - "sort_key": None, - "is_divided": False, - } - }, - "subcategories": {}, - "children": [("Discussion 1", TYPE_ENTRY), ("Discussion 2", TYPE_ENTRY)] - }, - "Chapter C": { - "entries": { - "Discussion": { - "id": "discussion2", - "sort_key": None, - "is_divided": False, - } - }, - "subcategories": {}, - "children": [("Discussion", TYPE_ENTRY)] - } - }, - "children": [("Chapter A", TYPE_SUBCATEGORY), ("Chapter B", TYPE_SUBCATEGORY), - ("Chapter C", TYPE_SUBCATEGORY)] - } - ) - def test_ids_empty(self): self.assertEqual(utils.get_discussion_categories_ids(self.course, self.user), [])