summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-06 07:59:06 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-10 12:01:00 +0200
commitcb2be9d5d57c34a70f0c549b780183f8c73aec4b (patch)
treef23412a2d6fbce2bac67995bfc07a8595f65594c
parent3d716467a9f046c7af4fb62c13e6b975c06c135f (diff)
Refs #29546 -- Removed django.utils.timezone.FixedOffset per deprecation timeline.
-rw-r--r--django/utils/timezone.py36
-rw-r--r--docs/ref/utils.txt9
-rw-r--r--docs/releases/3.1.txt2
-rw-r--r--tests/utils_tests/test_timezone.py25
4 files changed, 3 insertions, 69 deletions
diff --git a/django/utils/timezone.py b/django/utils/timezone.py
index 4c43377447..a87ec5fc33 100644
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -3,7 +3,6 @@ Timezone-related classes and functions.
"""
import functools
-import warnings
from contextlib import ContextDecorator
from datetime import datetime, timedelta, timezone, tzinfo
@@ -11,7 +10,6 @@ import pytz
from asgiref.local import Local
from django.conf import settings
-from django.utils.deprecation import RemovedInDjango31Warning
__all__ = [
'utc', 'get_fixed_timezone',
@@ -23,40 +21,6 @@ __all__ = [
]
-# UTC and local time zones
-
-ZERO = timedelta(0)
-
-
-class FixedOffset(tzinfo):
- """
- Fixed offset in minutes east from UTC. Taken from Python's docs.
-
- Kept as close as possible to the reference version. __init__ was changed
- to make its arguments optional, according to Python's requirement that
- tzinfo subclasses can be instantiated without arguments.
- """
-
- def __init__(self, offset=None, name=None):
- warnings.warn(
- 'FixedOffset is deprecated in favor of datetime.timezone',
- RemovedInDjango31Warning, stacklevel=2,
- )
- if offset is not None:
- self.__offset = timedelta(minutes=offset)
- if name is not None:
- self.__name = name
-
- def utcoffset(self, dt):
- return self.__offset
-
- def tzname(self, dt):
- return self.__name
-
- def dst(self, dt):
- return ZERO
-
-
# UTC time zone as a tzinfo instance.
utc = pytz.utc
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 06a9506ec9..fbbbb46f81 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -835,15 +835,6 @@ appropriate entities.
:class:`~datetime.tzinfo` instance that represents UTC.
-.. class:: FixedOffset(offset=None, name=None)
-
- A :class:`~datetime.tzinfo` subclass modeling a fixed offset from UTC.
- ``offset`` is an integer number of minutes east of UTC.
-
- .. deprecated:: 2.2
-
- Use :class:`datetime.timezone` instead.
-
.. function:: get_fixed_timezone(offset)
Returns a :class:`~datetime.tzinfo` instance that represents a time zone
diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt
index fdba88f035..2d2acf9745 100644
--- a/docs/releases/3.1.txt
+++ b/docs/releases/3.1.txt
@@ -230,6 +230,8 @@ in Django 3.1.
See :ref:`deprecated-features-2.2` for details on these changes, including how
to remove usage of these features.
+* ``django.utils.timezone.FixedOffset`` is removed.
+
* ``django.contrib.postgres.fields.FloatRangeField`` and
``django.contrib.postgres.forms.FloatRangeField`` are removed.
diff --git a/tests/utils_tests/test_timezone.py b/tests/utils_tests/test_timezone.py
index c6e5ece6c4..bfd71fb506 100644
--- a/tests/utils_tests/test_timezone.py
+++ b/tests/utils_tests/test_timezone.py
@@ -1,12 +1,10 @@
import datetime
-import pickle
from unittest import mock
import pytz
-from django.test import SimpleTestCase, ignore_warnings, override_settings
+from django.test import SimpleTestCase, override_settings
from django.utils import timezone
-from django.utils.deprecation import RemovedInDjango31Warning
CET = pytz.timezone("Europe/Paris")
EAT = timezone.get_fixed_timezone(180) # Africa/Nairobi
@@ -202,24 +200,3 @@ class TimezoneTests(SimpleTestCase):
def test_fixedoffset_negative_timedelta(self):
delta = datetime.timedelta(hours=-2)
self.assertEqual(timezone.get_fixed_timezone(delta).utcoffset(None), delta)
-
- @ignore_warnings(category=RemovedInDjango31Warning)
- def test_fixedoffset_pickle(self):
- self.assertEqual(pickle.loads(pickle.dumps(timezone.FixedOffset(0, 'tzname'))).tzname(''), 'tzname')
-
- def test_fixedoffset_deprecation(self):
- msg = 'FixedOffset is deprecated in favor of datetime.timezone'
- with self.assertWarnsMessage(RemovedInDjango31Warning, msg) as cm:
- timezone.FixedOffset()
- self.assertEqual(cm.filename, __file__)
-
- @ignore_warnings(category=RemovedInDjango31Warning)
- def test_fixedoffset_utcoffset(self):
- delta = datetime.timedelta(minutes=1)
- self.assertEqual(timezone.FixedOffset(1).utcoffset(None), delta)
-
- @ignore_warnings(category=RemovedInDjango31Warning)
- def test_fixedoffset_dst(self):
- ZERO = datetime.timedelta(minutes=0)
- delta = datetime.timedelta(hours=0)
- self.assertEqual(timezone.FixedOffset().dst(delta), ZERO)