-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add official support for Django 2.2. #46
Conversation
07c9314
to
81c8c54
Compare
Why coverage from 95% (master) to 97% (this branch) is show as decreased ? |
f5f9c5a
to
8037548
Compare
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.
Hey @joehybird!
Thank you for your patch but it seems to be doing more than simply adding support for Django 2.2.
Most of the changes you propose make sense but the fact they are all bundled together under a Add official support for Django 2.2. Improve coverage
commit doesn't.
Could you break down this single commit into multiple ones that do the following:
- Switch TravisCI configuration to use bionic dist.
- Improve coverage reporting.
- Add support for Django 2.2.
- Drop support for Django 2.0 and 2.1.
tests/tests.py
Outdated
@@ -35,6 +40,7 @@ def test_data_integrity(self): | |||
# the same data, even thought it's stored differently in the DB. | |||
self.assertEqual(value, model_test.pickle_field) | |||
self.assertEqual(value, model_test.compressed_pickle_field) | |||
self.assertEqual(None, model_test.nullable_pickle_field) |
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.
self.assertEqual(None, model_test.nullable_pickle_field) | |
self.assertIsNone(model_test.nullable_pickle_field) |
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.
good catch :)
picklefield/fields.py
Outdated
if django.VERSION < (2, 0): | ||
def from_db_value(self, value, expression, connection, context): | ||
return self.to_python(value) | ||
else: | ||
def from_db_value(self, value, expression, connection): | ||
return self.to_python(value) | ||
def from_db_value(self, value, expression, connection, context=None): | ||
return self.to_python(value) |
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 is still necessary unless you drop support for Django 1.11.
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.
It works in all versions with full coverage, but the django 3.0 warning is back. Pretty strange because master (3.1) is ok.
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.
@joehybird it will work but the idea is to avoid the warning on Django 3.0.
The context
argument is required on Django < 2.0 and will result in a warning if present on Django < 3.1.
Please restore the previous behavior.
tox.ini
Outdated
py35-{1.11,2.0,2.1,master}, | ||
py36-{1.11,2.0,2.1,master}, | ||
py37-{1.11,2.0,2.1,master} | ||
py{27,36,37,38}-1.11, |
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.
1.11 doesn't support 3.7 and 3.8, see https://djangoci.com/job/django-1.11/
tox.ini
Outdated
py36-{1.11,2.0,2.1,master}, | ||
py37-{1.11,2.0,2.1,master} | ||
py{27,36,37,38}-1.11, | ||
py{36,37,38}-{2.0,2.1,2.2,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.
2.0 and 2.1 are unsupported
2.2 supports 3.5 as well https://djangoci.com/job/django-2.2/
|
||
[testenv] | ||
basepython = | ||
py27: python2.7 | ||
py34: python3.4 | ||
py35: python3.5 |
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 2.2 LTS supports 3.5
def test_decode_error(self): | ||
def mock_decode_error(*args, **kwargs): | ||
raise Exception() | ||
|
||
model = MinimalTestingModel.objects.create(pickle_field={'foo': 'bar'}) | ||
model.save() | ||
|
||
self.assertEqual( | ||
{'foo': 'bar'}, MinimalTestingModel.objects.get(pk=model.pk).pickle_field | ||
) | ||
|
||
with patch('picklefield.fields.dbsafe_decode', mock_decode_error): | ||
encoded_value = dbsafe_encode({'foo': 'bar'}) | ||
self.assertEqual(encoded_value, MinimalTestingModel.objects.get(pk=model.pk).pickle_field) | ||
|
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.
What does this patch have to do with Django 2.2 support?
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.
Nothing, just coverage improvement 😄
Ok I will split it in different commits (should be easy... I hope so...) |
b4224fd
to
72b90d2
Compare
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.
Thanks for the extra mile, please revert the from_db_value
changes and I'll proceed with the merge.
picklefield/fields.py
Outdated
if django.VERSION < (2, 0): | ||
def from_db_value(self, value, expression, connection, context): | ||
return self.to_python(value) | ||
else: | ||
def from_db_value(self, value, expression, connection): | ||
return self.to_python(value) | ||
def from_db_value(self, value, expression, connection, context=None): | ||
return self.to_python(value) |
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.
@joehybird it will work but the idea is to avoid the warning on Django 3.0.
The context
argument is required on Django < 2.0 and will result in a warning if present on Django < 3.1.
Please restore the previous behavior.
Ok fixed :) |
Awesome thanks for everything! |
@charettes You can thank me with new release 🙏 |
No description provided.