diff --git a/openedx/core/lib/tests/pickled_data/pickled_datetime.txt b/openedx/core/lib/tests/pickled_data/pickled_datetime.txt new file mode 100644 index 0000000000..2ad3a2a3d7 Binary files /dev/null and b/openedx/core/lib/tests/pickled_data/pickled_datetime.txt differ diff --git a/openedx/core/lib/tests/test_cache_utils.py b/openedx/core/lib/tests/test_cache_utils.py index b6e40a94fc..4cbd008f3d 100644 --- a/openedx/core/lib/tests/test_cache_utils.py +++ b/openedx/core/lib/tests/test_cache_utils.py @@ -2,15 +2,16 @@ """ Tests for cache_utils.py """ - +from datetime import datetime from unittest import TestCase import ddt +import pytz import six from edx_django_utils.cache import RequestCache from mock import Mock -from openedx.core.lib.cache_utils import request_cached +from openedx.core.lib.cache_utils import request_cached, zunpickle @ddt.ddt @@ -297,3 +298,20 @@ class TestRequestCachedDecorator(TestCase): result = wrapped(3) assert result == 2 assert to_be_wrapped.call_count == 2 + + +def test_date_util_unpickling(): + """ + This tests is here to catch the dateutil object cache unpickling issue we faced twice on prod when attempting to + upgrade python-dateutil. This will help us catching such problem before it reaches production in future. + See https://openedx.atlassian.net/browse/BOM-2245 for more details on the issue. + + The pickle is saved to the pickled_datetime.txt file using the script below. + >>> import dateutil.parser + >>> from openedx.core.lib.cache_utils import zpickle + >>> with open('openedx/core/lib/tests/pickled_data/pickled_datetime.txt', 'wb') as file: + >>> file.write(zpickle(dateutil.parser.parse("2020-01-20T07:00:00Z"))) + """ + with open('openedx/core/lib/tests/pickled_data/pickled_datetime.txt', 'rb') as fp: + val = zunpickle(fp.read()) + assert val < datetime.now(pytz.utc) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 81c966ac13..e5e998647c 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -36,9 +36,6 @@ edx-enterprise==3.20.5 # Upgrading to 2.12.0 breaks several test classes due to API changes, need to update our code accordingly factory-boy==2.8.1 -# Newer versions need a more recent version of python-dateutil -freezegun==0.3.12 - # 4.0.0 dropped support for Python 3.5 inflect<4.0.0 @@ -79,9 +76,6 @@ path<13.2.0 # ARCHBOM-1141: pip-tools upgrade requires pip upgrade pip-tools<5.4 -# Upgrading to 2.5.3 on 2020-01-03 triggered "'tzlocal' object has no attribute '_std_offset'" errors in production -python-dateutil==2.4.0 - # stevedore 2.0.0 requires python >= 3.6 stevedore<2.0.0 diff --git a/requirements/edx-sandbox/py35.txt b/requirements/edx-sandbox/py35.txt index 06ad16a98f..e7446e40c5 100644 --- a/requirements/edx-sandbox/py35.txt +++ b/requirements/edx-sandbox/py35.txt @@ -24,7 +24,7 @@ numpy==1.16.5 # via -r requirements/edx-sandbox/py35.in, chem, matpl openedx-calc==1.0.9 # via -r requirements/edx-sandbox/py35.in pycparser==2.20 # via -r requirements/edx-sandbox/shared.txt, cffi pyparsing==2.2.0 # via -r requirements/edx-sandbox/py35.in, chem, matplotlib, openedx-calc -python-dateutil==2.4.0 # via -c requirements/edx-sandbox/../constraints.txt, matplotlib +python-dateutil==2.8.1 # via matplotlib pytz==2021.1 # via matplotlib random2==1.0.1 # via -r requirements/edx-sandbox/py35.in regex==2021.3.17 # via -r requirements/edx-sandbox/shared.txt, nltk diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index f60dc1a0aa..89265dde8d 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -188,7 +188,7 @@ pymongo==3.10.1 # via -c requirements/edx/../constraints.txt, -r requi pynliner==0.8.0 # via -r requirements/edx/base.in pyparsing==2.4.7 # via chem, openedx-calc, packaging, pycontracts pysrt==1.1.2 # via -r requirements/edx/base.in, edxval -python-dateutil==2.4.0 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.in, analytics-python, botocore, edx-ace, edx-drf-extensions, edx-enterprise, edx-event-routing-backends, edx-proctoring, icalendar, olxcleaner, ora2, xblock +python-dateutil==2.8.1 # via -r requirements/edx/base.in, analytics-python, botocore, edx-ace, edx-drf-extensions, edx-enterprise, edx-event-routing-backends, edx-proctoring, icalendar, olxcleaner, ora2, xblock python-levenshtein==0.12.2 # via -r requirements/edx/base.in python-memcached==1.59 # via -r requirements/edx/paver.txt python-slugify==4.0.1 # via code-annotations diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 836e6e3692..34949987a7 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -139,7 +139,7 @@ execnet==1.8.0 # via -r requirements/edx/testing.txt, pytest-xdist factory-boy==2.8.1 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt faker==7.0.1 # via -r requirements/edx/testing.txt, factory-boy filelock==3.0.12 # via -r requirements/edx/testing.txt, tox, virtualenv -freezegun==0.3.12 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt +freezegun==1.1.0 # via -r requirements/edx/testing.txt fs-s3fs==0.1.8 # via -r requirements/edx/testing.txt, django-pyfs fs==2.0.18 # via -r requirements/edx/testing.txt, django-pyfs, fs-s3fs, xblock future==0.18.2 # via -r requirements/edx/testing.txt, django-ses, edx-celeryutils, edx-enterprise, pycontracts, pyjwkest @@ -240,7 +240,7 @@ pytest-metadata==1.8.0 # via -r requirements/edx/testing.txt, pytest-json-rep pytest-randomly==3.5.0 # via -r requirements/edx/testing.txt pytest-xdist[psutil]==2.2.1 # via -r requirements/edx/testing.txt pytest==6.2.2 # via -r requirements/edx/testing.txt, pytest-attrib, pytest-cov, pytest-django, pytest-forked, pytest-json-report, pytest-metadata, pytest-randomly, pytest-xdist -python-dateutil==2.4.0 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt, analytics-python, botocore, edx-ace, edx-drf-extensions, edx-enterprise, edx-event-routing-backends, edx-proctoring, faker, freezegun, icalendar, olxcleaner, ora2, xblock +python-dateutil==2.8.1 # via -r requirements/edx/testing.txt, analytics-python, botocore, edx-ace, edx-drf-extensions, edx-enterprise, edx-event-routing-backends, edx-proctoring, faker, freezegun, icalendar, olxcleaner, ora2, xblock python-levenshtein==0.12.2 # via -r requirements/edx/testing.txt python-memcached==1.59 # via -r requirements/edx/testing.txt python-slugify==4.0.1 # via -r requirements/edx/testing.txt, code-annotations, transifex-client @@ -269,7 +269,7 @@ semantic-version==2.8.5 # via -r requirements/edx/testing.txt, edx-drf-extensi shapely==1.7.1 # via -r requirements/edx/testing.txt simplejson==3.17.2 # via -r requirements/edx/testing.txt, sailthru-client, super-csv, xblock-utils singledispatch==3.6.1 # via -r requirements/edx/testing.txt -six==1.15.0 # via -r requirements/edx/pip-tools.txt, -r requirements/edx/testing.txt, analytics-python, bleach, bok-choy, chem, codejail, crowdsourcehinter-xblock, cryptography, django-countries, django-simple-history, edx-ace, edx-bulk-grades, edx-ccx-keys, edx-django-release-util, edx-drf-extensions, edx-enterprise, edx-i18n-tools, edx-lint, edx-milestones, edx-rbac, edx-sphinx-theme, event-tracking, freezegun, fs, fs-s3fs, html5lib, httpretty, isodate, jsonschema, libsass, paver, pip-tools, pycontracts, pyjwkest, python-dateutil, python-memcached, python-swiftclient, singledispatch, social-auth-app-django, social-auth-core, sphinxcontrib-httpdomain, stevedore, tox, transifex-client, virtualenv, xblock +six==1.15.0 # via -r requirements/edx/pip-tools.txt, -r requirements/edx/testing.txt, analytics-python, bleach, bok-choy, chem, codejail, crowdsourcehinter-xblock, cryptography, django-countries, django-simple-history, edx-ace, edx-bulk-grades, edx-ccx-keys, edx-django-release-util, edx-drf-extensions, edx-enterprise, edx-i18n-tools, edx-lint, edx-milestones, edx-rbac, edx-sphinx-theme, event-tracking, fs, fs-s3fs, html5lib, httpretty, isodate, jsonschema, libsass, paver, pip-tools, pycontracts, pyjwkest, python-dateutil, python-memcached, python-swiftclient, singledispatch, social-auth-app-django, social-auth-core, sphinxcontrib-httpdomain, stevedore, tox, transifex-client, virtualenv, xblock slumber==0.7.1 # via -r requirements/edx/testing.txt, edx-bulk-grades, edx-enterprise, edx-rest-api-client smmap==4.0.0 # via -r requirements/edx/testing.txt, gitdb snowballstemmer==2.1.0 # via sphinx diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 92f7bf44a3..5549b579f5 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -135,7 +135,7 @@ execnet==1.8.0 # via pytest-xdist factory-boy==2.8.1 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.in faker==7.0.1 # via factory-boy filelock==3.0.12 # via tox, virtualenv -freezegun==0.3.12 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.in +freezegun==1.1.0 # via -r requirements/edx/testing.in fs-s3fs==0.1.8 # via -r requirements/edx/base.txt, django-pyfs fs==2.0.18 # via -r requirements/edx/base.txt, django-pyfs, fs-s3fs, xblock future==0.18.2 # via -r requirements/edx/base.txt, django-ses, edx-celeryutils, edx-enterprise, pycontracts, pyjwkest @@ -230,7 +230,7 @@ pytest-metadata==1.8.0 # via -r requirements/edx/testing.in, pytest-json-repo pytest-randomly==3.5.0 # via -r requirements/edx/testing.in pytest-xdist[psutil]==2.2.1 # via -r requirements/edx/testing.in pytest==6.2.2 # via -r requirements/edx/testing.in, pytest-attrib, pytest-cov, pytest-django, pytest-forked, pytest-json-report, pytest-metadata, pytest-randomly, pytest-xdist -python-dateutil==2.4.0 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.txt, analytics-python, botocore, edx-ace, edx-drf-extensions, edx-enterprise, edx-event-routing-backends, edx-proctoring, faker, freezegun, icalendar, olxcleaner, ora2, xblock +python-dateutil==2.8.1 # via -r requirements/edx/base.txt, analytics-python, botocore, edx-ace, edx-drf-extensions, edx-enterprise, edx-event-routing-backends, edx-proctoring, faker, freezegun, icalendar, olxcleaner, ora2, xblock python-levenshtein==0.12.2 # via -r requirements/edx/base.txt python-memcached==1.59 # via -r requirements/edx/base.txt python-slugify==4.0.1 # via -r requirements/edx/base.txt, code-annotations, transifex-client @@ -258,7 +258,7 @@ semantic-version==2.8.5 # via -r requirements/edx/base.txt, edx-drf-extensions shapely==1.7.1 # via -r requirements/edx/base.txt simplejson==3.17.2 # via -r requirements/edx/base.txt, sailthru-client, super-csv, xblock-utils singledispatch==3.6.1 # via -r requirements/edx/testing.in -six==1.15.0 # via -r requirements/edx/base.txt, analytics-python, bleach, bok-choy, chem, codejail, crowdsourcehinter-xblock, cryptography, django-countries, django-simple-history, edx-ace, edx-bulk-grades, edx-ccx-keys, edx-django-release-util, edx-drf-extensions, edx-enterprise, edx-i18n-tools, edx-lint, edx-milestones, edx-rbac, event-tracking, freezegun, fs, fs-s3fs, html5lib, httpretty, isodate, libsass, paver, pycontracts, pyjwkest, python-dateutil, python-memcached, python-swiftclient, singledispatch, social-auth-app-django, social-auth-core, stevedore, tox, transifex-client, virtualenv, xblock +six==1.15.0 # via -r requirements/edx/base.txt, analytics-python, bleach, bok-choy, chem, codejail, crowdsourcehinter-xblock, cryptography, django-countries, django-simple-history, edx-ace, edx-bulk-grades, edx-ccx-keys, edx-django-release-util, edx-drf-extensions, edx-enterprise, edx-i18n-tools, edx-lint, edx-milestones, edx-rbac, event-tracking, fs, fs-s3fs, html5lib, httpretty, isodate, libsass, paver, pycontracts, pyjwkest, python-dateutil, python-memcached, python-swiftclient, singledispatch, social-auth-app-django, social-auth-core, stevedore, tox, transifex-client, virtualenv, xblock slumber==0.7.1 # via -r requirements/edx/base.txt, edx-bulk-grades, edx-enterprise, edx-rest-api-client smmap==4.0.0 # via gitdb social-auth-app-django==4.0.0 # via -r requirements/edx/base.txt