Opened 7 years ago

Last modified 7 years ago

#28421 closed Cleanup/optimization

Formset test contain too many assert — at Version 1

Reported by: Windson yang Owned by: nobody
Component: Forms Version: 1.11
Severity: Normal Keywords:
Cc: 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 Windson yang)

In
https://github.com/django/django/blob/master/tests/forms_tests/tests/test_formsets.py#L509

It contains

self.assertHTMLEqual(
            '\n'.join(form_output),
            """<li>Choice: <input type="text" name="choices-0-choice" value="Calexico" /></li>
<li>Votes: <input type="number" name="choices-0-votes" value="100" /></li>
<li>Delete: <input type="checkbox" name="choices-0-DELETE" /></li>

to check the output of formset, and also have

self.assertTrue(formset.is_valid())
self.assertEqual(
            [form.cleaned_data for form in formset.forms],
            [
                {'votes': 100, 'DELETE': False, 'choice': 'Calexico'},
                {'votes': 900, 'DELETE': True, 'choice': 'Fergie'},
                {},
            ]
        )

to check the deletion.maybe we should divide the function into multiple small tests.

Change History (1)

comment:1 by Windson yang, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top