dealertrack / django-rest-framework-braces

Collection of utilities for working with django rest framework (DRF)
Other
72 stars 21 forks source link

Three tests fail on DRF 3.13 #32

Open jayvdb opened 2 years ago

jayvdb commented 2 years ago

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 https://github.com/encode/django-rest-framework/compare/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 commented 2 years ago

I've bisected the commits in drf, and https://github.com/encode/django-rest-framework/commit/fdb49314754ff13d91c6eec7ccdb8ece52bea9eb is what causes these three failures.