Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24667 closed Bug (fixed)

Some tests in model_field suite don't actually do anything

Reported by: Yoong Kang Lim Owned by: Yoong Kang Lim
Component: Testing framework Version: 1.8
Severity: Normal Keywords: tests
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I ran the model_fields test suite. In this suite there is a test called test_cardinality_m2m.

The test is supposed to iterate through a collection of fields and run some tests on each field in the collection.

These asserts never actually get called because the collection is empty.

To reproduce, simply run the following:

PYTHONPATH=..$PYTHONPATH ./runtests.py model_fields

The other tests in model_fields look like they may have the same problem.

Change History (5)

comment:1 by Baptiste Mispelon, 9 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

Hi,

If I understand correctly, the problem is that a generator comprehension is used so it can only be iterated over once.

We should use a list comprehension instead.

comment:2 by Yoong Kang Lim, 9 years ago

Owner: changed from nobody to Yoong Kang Lim
Status: newassigned

comment:3 by Yoong Kang Lim, 9 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 36eab95e:

Fixed #24667 --- Repaired model_fields cardinality test

comment:5 by Tim Graham <timograham@…>, 9 years ago

In b8f203b3:

[1.8.x] Fixed #24667 --- Repaired model_fields cardinality test

Backport of 36eab95e7fde7fad4368192ddbef4e2dbb32dc91 from master

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