8000 removed checks meant for python version less then 3.6. by auvipy · Pull Request #19432 · django/django · GitHub
[go: up one dir, main page]

Skip to content

removed checks meant for python version less then 3.6. #19432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions django/utils/timezone.py
D7E8
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ def localtime(value=None, timezone=None):
value = now()
if timezone is None:
timezone = get_current_timezone()
# Emulate the behavior of astimezone() on Python < 3.6.
if is_naive(value):
raise ValueError("localtime() cannot be applied to a naive datetime")
return value.astimezone(timezone)


Expand Down Expand Up @@ -249,9 +246,6 @@ def make_naive(value, timezone=None):
"""Make an aware datetime.datetime naive in a given time zone."""
if timezone is None:
timezone = get_current_timezone()
# Emulate the behavior of astimezone() on Python < 3.6.
if is_naive(value):
raise ValueError("make_naive() cannot be applied to a naive datetime")
return value.astimezone(timezone).replace(tzinfo=None)


Expand Down
15 changes: 0 additions & 15 deletions tests/utils_tests/test_timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ def test_now(self):
self.assertTrue(timezone.is_naive(timezone.now()))

def test_localdate(self):
naive = datetime.datetime(2015, 1, 1, 0, 0, 1)
with self.assertRaisesMessage(
ValueError, "localtime() cannot be applied to a naive datetime"
):
timezone.localdate(naive)
with self.assertRaisesMessage(
ValueError, "localtime() cannot be applied to a naive datetime"
):
timezone.localdate(naive, timezone=EAT)

aware = datetime.datetime(2015, 1, 1, 0, 0, 1, tzinfo=ICT)
self.assertEqual(
timezone.localdate(aware, timezone=EAT), datetime.date(2014, 12, 31)
Expand Down Expand Up @@ -149,11 +139,6 @@ def test_make_naive(self):
datetime.datetime(2011, 9, 1, 13, 20, 30),
)

with self.assertRaisesMessage(
ValueError, "make_naive() cannot be applied to a naive datetime"
):
timezone.make_naive(datetime.datetime(2011, 9, 1, 13, 20, 30), EAT)

def test_make_naive_no_tz(self):
self.assertEqual(
timezone.make_naive(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)),
Expand Down
0