#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by browniebroke:
Old description:
> There's quite a lot of unit tests that have been rewritten 1:1 from
> doctests. These tests tend to verify all aspects of a certain feature at
> once, they modify the state of the database throughout the whole test and
> by the end of the test no one really knows what the database state is
> supposed to be.
>
> For example,
> `modeltests.generic_relations.GenericRelationsTests.test_generic_relations`
> walks through most of the features supported by `GenericForeignKeys`, it
> is 130 lines long and in case the last assertion fails, you'll have to
> spend ridiculous amounts of time figuring out what happened.
>
> A likely incomplete list of similar tests:[[BR]]
> `modeltests.basic.ModelTest.test_lookup`[[BR]]
> `modeltests.basic.ModelTest.test_object_creation`[[BR]]
> ~~modeltests.custom_columns.CustomColumnsTests.test_db_column~~[[BR]]
> `modeltests.custom_managers.CustomManagerTests.test_manager`[[BR]]
> `modeltests.custom_pk.CustomPKTests.test_custom_pk`[[BR]]
> `modeltests.defer.DeferTests.test_defer`[[BR]]
> `modeltests.expressions.ExpressionsTests.test_filter`[[BR]]
> `modeltests.field_subclassing.CustomField.test_custom_field`[[BR]]
> `modeltests.files.FileStorageTests.test_files`[[BR]]
> ~~modeltests.get_or_create.GetOrCreateTests.test_get_or_create~~[[BR]]
> ~~modeltests.m2m_recursive.RecursiveM2MTests.test_recursive_m2m~~[[BR]]
> `modeltests.m2m_signals.ManyToManySignalsTest`[[BR]]
> ~~modeltests.m2m_through.M2mThroughTests~~[[BR]]
> `modeltests.m2m_through_regress.M2MThroughTestCase`[[BR]]
> `modeltests.model_formsets.ModelFormsetTests`[[BR]]
> `modeltests.model_forms.OldFormForXTests.test_with_data` (This one has
> more than 500 lines!)[[BR]]
> `modeltests.model_inheritance.ModelInheritanceTests`[[BR]]
> `modeltests.model_package.ModelPackageTests.test_model_packages`[[BR]]
> `modeltests.order_with_respect_to.OrderWithRespectToTests.test_basic`[[BR]]
> `modeltests.signals.SignalTests.test_basic`
>
> I only went through modeltests/*/tests.py; I might have overlooked a few
> tests.
>
> This ticket is meant to track all of them; each time a test is updated,
> we can strike it out in the list above and once there is no item left, we
> can close this. The point is to make the test suite help developers as
> much as possible.
New description:
There's quite a lot of unit tests that have been rewritten 1:1 from
doctests. These tests tend to verify all aspects of a certain feature at
once, they modify the state of the database throughout the whole test and
by the end of the test no one really knows what the database state is
supposed to be.
For example,
`modeltests.generic_relations.GenericRelationsTests.test_generic_relations`
walks through most of the features supported by `GenericForeignKeys`, it
is 130 lines long and in case the last assertion fails, you'll have to
spend ridiculous amounts of time figuring out what happened.
A likely incomplete list of similar tests:[[BR]]
~~modeltests.basic.ModelTest.test_lookup~~[[BR]]
`modeltests.basic.ModelTest.test_object_creation`[[BR]]
~~modeltests.custom_columns.CustomColumnsTests.test_db_column~~[[BR]]
`modeltests.custom_managers.CustomManagerTests.test_manager`[[BR]]
`modeltests.custom_pk.CustomPKTests.test_custom_pk`[[BR]]
`modeltests.defer.DeferTests.test_defer`[[BR]]
`modeltests.expressions.ExpressionsTests.test_filter`[[BR]]
`modeltests.field_subclassing.CustomField.test_custom_field`[[BR]]
`modeltests.files.FileStorageTests.test_files`[[BR]]
~~modeltests.get_or_create.GetOrCreateTests.test_get_or_create~~[[BR]]
~~modeltests.m2m_recursive.RecursiveM2MTests.test_recursive_m2m~~[[BR]]
`modeltests.m2m_signals.ManyToManySignalsTest`[[BR]]
~~modeltests.m2m_through.M2mThroughTests~~[[BR]]
`modeltests.m2m_through_regress.M2MThroughTestCase`[[BR]]
`modeltests.model_formsets.ModelFormsetTests`[[BR]]
`modeltests.model_forms.OldFormForXTests.test_with_data` (This one has
more than 500 lines!)[[BR]]
`modeltests.model_inheritance.ModelInheritanceTests`[[BR]]
`modeltests.model_package.ModelPackageTests.test_model_packages`[[BR]]
`modeltests.order_with_respect_to.OrderWithRespectToTests.test_basic`[[BR]]
`modeltests.signals.SignalTests.test_basic`
I only went through modeltests/*/tests.py; I might have overlooked a few
tests.
This ticket is meant to track all of them; each time a test is updated, we
can strike it out in the list above and once there is no item left, we can
close this. The point is to make the test suite help developers as much as
possible.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:36>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.697267f280556629eb8e94a95ced6fa3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.