-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fixes for Django 2.1 #6044
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
Fixes for Django 2.1 #6044
Conversation
Look good. Anyone else? |
#6043 has been merged - would be great if you could rebase. |
tests/test_fields.py
Outdated
"""Django 2.1 uses datetime.timezone.utc | ||
|
||
Ref: https://github.com/django/django/pull/9484#issuecomment-399169042""" | ||
return tz.utcoffset(None).total_seconds() == 0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check seems a bit funky. Is there no better way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - I am also not happy with it.
Asked about in the commit making this necessary: django/django#9484 (comment).
If Django does not change get_default_timezone
itself we could also change the test to compare another (the new) "utc" (which is datetime.timezone.utc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In retrospect, I don't think it's incredibly important to block this PR over the test code. It could be improved, but it's not worth blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour here will be restored for Django v2.1b2. So if we can keep this in a separate commit it'll just be a revert at that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour here will be restored for Django v2.1b2
Did they revert the original PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No code changes AFAIK.
The assumption might be because of https://code.djangoproject.com/ticket/29514 being accepted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour change was reverted in django/django@2ec151e. I'd drop this and wait for v2.1b2 to remove from allowed failures.
Should become green now (also master). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say let's hold off until we get some kind of response in regards to django/django#9484. Otherwise, looks good to me.
django/django#10081. We'll see what Tim says. |
tests/test_parsers.py
Outdated
assert file_obj._size == 14 | ||
try: | ||
size = file_obj.size | ||
except AttributeError: # before Django 2.1 _size was private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the relevant change is django/django@a5406fe. I think size
would work in older Django versions.
tests/test_permissions.py
Outdated
# add, change, delete built in to django | ||
) | ||
|
||
if django.VERSION <= (2, 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant <
.
@blueyed - could you push Tim's suggested changes? It would be good to fix the test suite. |
Rebased. |
tests/test_parsers.py
Outdated
@@ -62,7 +62,8 @@ def test_parse(self): | |||
self.stream.seek(0) | |||
data_and_files = parser.parse(self.stream, None, self.parser_context) | |||
file_obj = data_and_files.files['file'] | |||
assert file_obj._size == 14 | |||
size = file_obj.size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for size variable.
Removed e22fb41. Will require 2.1b2 now. commit e22fb41c
Author: Daniel Hahler <[email protected]>
Date: Thu Jun 21 18:45:50 2018 +0200
Fix TestDefaultTZDateTimeField
---
tests/test_fields.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
──────────────────────────────────────────────────────────────────────────────────────────────
modified: tests/test_fields.py
──────────────────────────────────────────────────────────────────────────────────────────────
@ tests/test_fields.py:1346 @ def setup_class(cls):
cls.field = serializers.DateTimeField()
cls.kolkata = pytz.timezone('Asia/Kolkata')
+ @staticmethod
+ def is_utc(tz):
+ """Django 2.1 uses datetime.timezone.utc
+
+ Ref: https://github.com/django/django/pull/9484#issuecomment-399169042"""
+ return tz.utcoffset(None).total_seconds() == 0.0
+
def test_default_timezone(self):
- assert self.field.default_timezone() == utc
+ assert self.is_utc(self.field.default_timezone())
def test_current_timezone(self):
- assert self.field.default_timezone() == utc
+ assert self.is_utc(self.field.default_timezone())
activate(self.kolkata)
assert self.field.default_timezone() == self.kolkata
deactivate()
- assert self.field.default_timezone() == utc
+ assert self.is_utc(self.field.default_timezone())
@pytest.mark.skipif(pytz is None, reason='pytz not installed') |
.travis.yml
Outdated
@@ -42,7 +42,6 @@ matrix: | |||
|
|||
allow_failures: | |||
- env: DJANGO=master | |||
- env: DJANGO=2.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this line for now and we’ll merge. We can add this after the next release. (Which should be the 16th.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, removed ac39602.
Thanks! |
Needs #6043 also.