Opened 11 years ago

Last modified 2 weeks ago

#21286 assigned Bug

Fix commented out tests in serializers.test_data

Reported by: Tim Graham Owned by: Adam Zapletal
Component: Core (Serialization) Version: dev
Severity: Normal Keywords:
Cc: bmispelon@…, Adam Zapletal, Ülgen Sarıkavak Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Claude Paroz)

tests/serializers/test_data.py contains some commented out items in the test_data list. I think it may be because not all serializers support those items. If this is the case, we should make appropriate modifications so the tests are run where they are supported and skipped where not.

Change History (29)

comment:1 by Baptiste Mispelon, 11 years ago

Cc: bmispelon@… added

While looking into this, I believe I found the reason why some of the tests are commented: https://github.com/django/django/blob/8d6953d55c3aba04bbaf0f268499d6e405c653ff/tests/serializers_regress/models.py#L168-L170

The comment is not completely correct however because a few of the commented out models trigger and error immediately, regardless of the backend (TypeError: 'primary_key' is not a valid argument for ...).

  • FilePKData, ImagePKData and NullBooleanPKData can be deleted because of this.
  • DatePKData, DateTimePKData, TimePKData and TextPKData might be database-dependent (they all work under sqlite).
  • Test case 51 (FileData) might be worth looking into a bit deeper. It fails when uncommented and I believe it might be caused by the weird FileField.__eq__ implementation.

comment:2 by Claude Paroz, 9 years ago

FileField and NULL value issue is tracked in #10244.

comment:3 by Claude Paroz <claude@…>, 8 years ago

In d02fc8d:

Refs #21286 -- Enabled serializer tests with date/datetime pk model

comment:4 by Claude Paroz <claude@…>, 7 years ago

In 01c6a3e:

Refs #21286 -- Enabled serializer tests with time pk model

comment:5 by Claude Paroz, 7 years ago

Description: modified (diff)
Summary: Fix commented out tests in serializers_regressFix commented out tests in serializers.test_data

comment:6 by Florian Apolloner, 7 years ago

@claude Your latest commit caused quite a few failures, did you forget to commit some code?

comment:7 by Claude Paroz, 7 years ago

Argh, sorry! I was fooled by the fact the missing YAML lib in my test virtualenv wasn't showing by a skipped ('s') test. I will revert ASAP and try to work on that skip issue.

comment:8 by Claude Paroz <claude@…>, 7 years ago

In 256182c4:

Revert "Refs #21286 -- Enabled serializer tests with time pk model"

This reverts commit 01c6a3e227b645e8dea97e9befecd23d1d3b8581.
Unfortunately, the YAML serializer is not yet able to cope with time values.

comment:9 by Claude Paroz, 7 years ago

Missing skip issue in #28610.

comment:10 by Adam Zapletal, 10 months ago

Cc: Adam Zapletal added

comment:11 by Adam Zapletal, 10 months ago

Has patch: set

I started looking at this ticket today to see if it was still valid and submitted a small PR removing what I believe are some invalid commented-out test cases.

Last edited 10 months ago by Adam Zapletal (previous) (diff)

comment:12 by Mariusz Felisiak <felisiak.mariusz@…>, 10 months ago

In 3d4fe39b:

Refs #21286 -- Removed invalid commented out models and tests from serializer tests.

FileField/ImageField cannot be primary keys, so serialization support
for this case will not be implemented.

XMLField was removed in d1290b5b43485c7018ba92981d34c1f96614924e.

comment:13 by Mariusz Felisiak, 10 months ago

Has patch: unset

comment:14 by Ülgen Sarıkavak, 9 months ago

Cc: Ülgen Sarıkavak added

comment:15 by Adam Zapletal, 6 weeks ago

Owner: changed from nobody to Adam Zapletal
Status: newassigned

comment:16 by Adam Zapletal, 6 weeks ago

Has patch: set

I opened a PR uncommenting and adding a fix for TimePKData.

comment:17 by Sarah Boyce <42296566+sarahboyce@…>, 6 weeks ago

In b9aa323:

Refs #21286 -- Fixed YAML serialization of TimeField primary key.

Handling for PyYAML not being able to serialize datetime.time
values is moved from handle_field to _value_from_field as only
non-primary key, non-relation fields are passed into handle_field.

comment:18 by Sarah Boyce, 6 weeks ago

Has patch: unset

comment:19 by Adam Zapletal, 6 weeks ago

Has patch: set

I opened a PR uncommenting and adding a fix for TextPKData.

comment:20 by Sarah Boyce, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:21 by Sarah Boyce <42296566+sarahboyce@…>, 3 weeks ago

In 1636912b:

Refs #21286 -- Fixed serializer test with primary key TextField.

comment:22 by Sarah Boyce, 3 weeks ago

Has patch: unset

comment:23 by Sarah Boyce, 3 weeks ago

Triage Stage: Ready for checkinAccepted

comment:24 by Adam Zapletal, 3 weeks ago

Has patch: set

I opened a PR enabling the ImageField data tests in the same way that FileField is currently tested.

comment:25 by Sarah Boyce, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:26 by Sarah Boyce <42296566+sarahboyce@…>, 3 weeks ago

In d2f2a6a:

Refs #21286 -- Enabled ImageField test cases in serializer data tests.

This aligns ImageField to be tested in the same way as FileField.
The commented-out test also exists for FileField and relates to #10244.

comment:27 by Sarah Boyce, 3 weeks ago

Has patch: unset
Triage Stage: Ready for checkinAccepted

comment:28 by Adam Zapletal, 3 weeks ago

The final commented-out tests are blocked by #10244. I'll shift my focus to that ticket.

comment:29 by Sarah Boyce <42296566+sarahboyce@…>, 2 weeks ago

In 3d508ec:

Refs #21286 -- Fixed serializers tests if Pillow isn't installed.

Note: See TracTickets for help on using tickets.
Back to Top