﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18586	Rewrite unit tests migrated from doctests	Michal Petrucha	ChillarAnand	"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."	Cleanup/optimization	assigned	Testing framework	dev	Normal		unit tests	Peter Zsoldos	Accepted	0	0	0	0	1	0
