Skip to content
/ django Public

Rewrote form widget tests as proper unittests.#5209

Merged
prestontimmons merged 1 commit intodjango:masterfrom
prestontimmons:form-test-cleanup
Sep 1, 2015
Merged

Rewrote form widget tests as proper unittests.#5209
prestontimmons merged 1 commit intodjango:masterfrom
prestontimmons:form-test-cleanup

Conversation

@prestontimmons
Copy link
Contributor

No description provided.

@prestontimmons
Copy link
Contributor Author

Here's an overview of where tests are moved to:

FormsWidgetTests

  • Tests are broken up and moved to individual files in widget_tests.
  • Duplicate tests removed from widgets that inherit TextInput and Select. For example, we don't need to test contstructor attrs handling in every widget, or that generators work as a choices argument in every Select based widget. It's enough to do this once in the parent widget.
  • test_multi and test_multiwidget are split into widget_tests/test_multiwidget.py and field_tests/test_multivaluefield.py. The widget and field tests were previously mingled together.

FormsI18NWidgetsTests

  • These are moved into the individual widget test files with a name similar to test_l10n.

WidgetTests

  • test_12048 moved to widget_tests.test_multiwidget.test_deepcopy

ClearableFileInputTests

  • Moved into test_clearablefileinput.py except for one case: test_render_custom_template.

SelectDateWidgetTests

  • Split into widget_tests/test_selectdatewidget.py and field_tests.test_datefield.py. The widget and field tests were previously mingled together.

SelectWidgetTests

  • Moved to widget_tests/test_select.py

The following tests were kept in the forms_tests/tests/test_widget.py file:

FormsWidgetTests.test_radiofieldrenderer
FormsWidgetTests.test_subwidget
FormsWidgetTests.test_sub_widget_html_safe
FormsWidgetTests.test_choice_input_html_safe
FormsWidgetTests.test_choice_field_renderer_html_safe
ClearableFileInputTests.test_render_custom_template

These are all obsoleted by the new rendering API.

LiveWidgetTests

This is more a ModelForm test than a Widget test and should be moved to a more appropriate place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this initialization needs to be done in setUpClass() or if doing it at the class-level would work?

class DateInputTest(WidgetTest):
    widget = DateInput()

@timgraham
Copy link
Member

Looks good. I just did a few cleanups along the way: http://dpaste.com/0DTFH6C
There are still a few lines > 119 chars if you could fix them. Hopefully we'll have automated enforcement soon. Please merge at your convenience.

This is preparation for landing the template-based widget rendering
patch and goes a long way to making these tests more useful for future
development. The old doctest heritage is strong here.
@prestontimmons prestontimmons merged commit 4c30fa9 into django:master Sep 1, 2015
@prestontimmons
Copy link
Contributor Author

Great. Thanks for reviewing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants