Skip to content
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

Three tests fail on DRF 3.13 #32

Open
jayvdb opened this issue Jan 9, 2022 · 1 comment · Fixed by holdenk/django-rest-framework-braces#2 · May be fixed by #34
Open

Three tests fail on DRF 3.13 #32

jayvdb opened this issue Jan 9, 2022 · 1 comment · Fixed by holdenk/django-rest-framework-braces#2 · May be fixed by #34

Comments

@jayvdb
Copy link

jayvdb commented Jan 9, 2022

These three tests started failing with https://github.com/encode/django-rest-framework/releases/tag/3.13.0, relnotes https://github.com/encode/django-rest-framework/blob/master/docs/community/3.13-announcement.md (but the main change there doesnt seem related), so something in encode/django-rest-framework@3.12.4...3.13.0

[   53s] =================================== FAILURES ===================================
[   53s] ____________________ TestFormSerializerBase.test_get_field _____________________
[   53s] 
[   53s] self = <drf_braces.tests.serializers.test_form_serializer.TestFormSerializerBase testMethod=test_get_field>
[   53s] 
[   53s]     def test_get_field(self):
[   53s]         serializer = self.serializer_class()
[   53s]         form_field = forms.ChoiceField(
[   53s]             choices=[('foo', 'bar')],
[   53s]             required=False,
[   53s]             validators=[mock.sentinel.validator],
[   53s]         )
[   53s]     
[   53s]         field = serializer._get_field(form_field, fields.ChoiceField)
[   53s]     
[   53s]         self.assertIsInstance(field, fields.ChoiceField)
[   53s] >       self.assertTrue(field.allow_blank)
[   53s] E       AssertionError: False is not true
[   53s] 
[   53s] drf_braces/tests/serializers/test_form_serializer.py:251: AssertionError
[   53s] _________________ TestFormSerializerBase.test_get_field_kwargs _________________
[   53s] 
[   53s] self = <drf_braces.tests.serializers.test_form_serializer.TestFormSerializerBase testMethod=test_get_field_kwargs>
[   53s] 
[   53s]     def test_get_field_kwargs(self):
[   53s]         serializer = self.serializer_class()
[   53s]         form_field = forms.IntegerField(
[   53s]             max_value=500,
[   53s]             initial=100,
[   53s]             required=True,
[   53s]             validators=[mock.sentinel.validator],
[   53s]         )
[   53s]     
[   53s]         kwargs = serializer._get_field_kwargs(form_field, fields.IntegerField)
[   53s]     
[   53s] >       self.assertDictContainsSubset({
[   53s]             'default': 100,
[   53s]             'validators': [mock.sentinel.validator, mock.ANY],
[   53s]         }, kwargs)
[   53s] E       AssertionError: Missing: 'validators'
[   53s] 
[   53s] drf_braces/tests/serializers/test_form_serializer.py:269: AssertionError
[   53s] __________________ TestFormSerializerBase.test_validate_fail ___________________
[   53s] 
[   53s] self = <drf_braces.tests.serializers.test_form_serializer.TestFormSerializerBase testMethod=test_validate_fail>
[   53s] 
[   53s]     def test_validate_fail(self):
[   53s]         self.serializer_class.Meta.failure_mode = 'fail'
[   53s]         serializer = self.serializer_class(data={
[   53s]             'foo': 'hello',
[   53s]             'bar': '100',
[   53s]             'other': 'stuff',
[   53s]         })
[   53s]     
[   53s]         self.assertFalse(serializer.is_valid())
[   53s] >       self.assertDictEqual(serializer.errors, {
[   53s]             'other': ['Enter a valid date/time.'],
[   53s]         })
[   53s] E       AssertionError: {'happy': [ErrorDetail(string='This field is required.', code='required')]} != {'other': ['Enter a valid date/time.']}
[   53s] E       - {'happy': [ErrorDetail(string='This field is required.', code='required')]}
[   53s] E       + {'other': ['Enter a valid date/time.']}
[   53s] 
[   53s] drf_braces/tests/serializers/test_form_serializer.py:328: AssertionError
@jayvdb jayvdb changed the title Three tests fail on Django 4 Three tests fail on DRF 3.13 May 14, 2022
@jayvdb
Copy link
Author

jayvdb commented May 14, 2022

I've bisected the commits in drf, and encode/django-rest-framework@fdb4931 is what causes these three failures.

jayvdb added a commit to jayvdb/django-rest-framework-braces that referenced this issue May 15, 2022
@jayvdb jayvdb linked a pull request May 15, 2022 that will close this issue
jayvdb added a commit to jayvdb/django-rest-framework-braces that referenced this issue Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant