[Django] #18586: Rewrite unit tests migrated from doctests

79 views
Skip to first unread message

Django

unread,
Jul 7, 2012, 7:54:15 AM7/7/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------
Reporter: koniiiik | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords: unit tests
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------
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.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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 7, 2012, 8:03:42 AM7/7/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner: anonymous
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Uncategorized | Resolution:
Severity: Normal | Triage Stage:
Keywords: unit tests | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anonymous):

* owner: nobody => anonymous
* needs_docs: => 0
* status: new => assigned
* needs_tests: => 0
* needs_better_patch: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:1>

Django

unread,
Jul 7, 2012, 8:04:12 AM7/7/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: | Status: new
Cleanup/optimization | Version: master
Component: Uncategorized | Resolution:
Severity: Normal | Triage Stage:
Keywords: unit tests | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by judy2k):

* owner: anonymous => judy2k
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:2>

Django

unread,
Jul 7, 2012, 8:07:45 AM7/7/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner: anonymous
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Uncategorized | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: unit tests | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by judy2k):

* owner: judy2k => anonymous

* status: new => assigned

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:3>

Django

unread,
Jul 7, 2012, 8:10:50 AM7/7/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: new
Component: Uncategorized | 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
--------------------------------------+------------------------------------
Changes (by judy2k):

* owner: anonymous => judy2k

* status: assigned => new


Comment:

Last attempt to get the status of this ticket correct.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:4>

Django

unread,
Jul 8, 2012, 7:03:11 AM7/8/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: assigned
Component: Uncategorized | 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
--------------------------------------+------------------------------------
Changes (by judy2k):

* status: new => assigned


Comment:

Basic test refactorings now committed at
https://github.com/bedmondmark/django/tree/test_refactor - I'll issue a
Pull Request when I've finished the whole lot.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:5>

Django

unread,
Jul 8, 2012, 8:14:35 AM7/8/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: assigned
Component: Uncategorized | 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
--------------------------------------+------------------------------------

Comment (by koniiiik):

Found another candidate:
`regressiontests.defer_regress.DeferRegressionTest.test_basic`

IMO, this test is broken because its results depend on the order of
execution of tests as it accesses the global model class storage. This
means it won't be that easy to rewrite this test.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:6>

Django

unread,
Dec 24, 2012, 4:17:10 PM12/24/12
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------
Changes (by aaugustin):

* component: Uncategorized => Testing framework


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:7>

Django

unread,
Mar 18, 2013, 7:10:06 PM3/18/13
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by modi.konark@…):

Tried Merging the pull request by koniiik, there were lot of conflicts.
The test directory layout has changed and also the conventions used needed
to be re-worked.


Will be re-writing the tests and issue a pull request as and when they are
done.

https://github.com/django/django/pull/923 , for the test " Custom Columns
" .

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:8>

Django

unread,
Mar 19, 2013, 4:37:12 AM3/19/13
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by claudep):

I'd just like to note that cutting single tests in multiple tests has a
cost for the test suite, as the database is flushed between tests. So it's
right and fine to separate tests when testing different features, but
don't just create test methods for each single database request.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:9>

Django

unread,
Mar 19, 2013, 6:59:16 PM3/19/13
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by Carl Meyer <carl@…>):

In [changeset:"483e1b807e7a3c9e49fe5fcbf9b1300ef98a381c"]:
{{{
#!CommitTicketReference repository=""
revision="483e1b807e7a3c9e49fe5fcbf9b1300ef98a381c"
Refs #18586 -- Split out long custom_columns lookup test into multiple
tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:10>

Django

unread,
Mar 19, 2013, 7:00:32 PM3/19/13
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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 carljm:

Old description:

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]]

--

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:11>

Django

unread,
Mar 19, 2013, 7:01:12 PM3/19/13
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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 carljm:

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]]

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.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:12>

Django

unread,
Mar 19, 2013, 7:02:34 PM3/19/13
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by carljm):

@claudep If you want to look over the initial PR I just committed and
comment on whether you think these tests are split up too finely, I'd like
to make sure we have consensus on the right level of test granularity
before @modi.konark moves forward with more PRs.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:13>

Django

unread,
Mar 20, 2013, 5:08:50 AM3/20/13
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by claudep):

Carl, I guess we're also entering personal style here.
For example in that commit, I would have regrouped
`test_get_first_name`/`test_filter_first_name` and probably also the 3
last
(`test_get_all_authors_for_an_article`/`test_get_all_articles_for_an_author`/`test_get_author_m2m_relation`),
particularly as they are only querying data.
But once again, this is just me, and I can understand others have
different approaches.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:14>

Django

unread,
Feb 10, 2014, 5:27:50 AM2/10/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"0d98422b1365ae1e75051036936aab31248d5ee1"]:
{{{
#!CommitTicketReference repository=""
revision="0d98422b1365ae1e75051036936aab31248d5ee1"
Refactored RecursiveM2MTests into smaller pieces, refs #18586.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:15>

Django

unread,
Apr 14, 2014, 3:50:21 PM4/14/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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 julien:

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.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.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:16>

Django

unread,
Apr 14, 2014, 3:53:15 PM4/14/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by Liav3000):

Hi. I just created https://github.com/liavkoren-
vmfarms/djangoDev/tree/ticket_18586 which refactors
modeltests.get_or_create.GetOrCreateTests.test_get_or_create into smaller
units and changes comments over to docstrings. I'd be happy to continue
crunching through the tests in this ticket if everything is okay with that
first set of changes.

Thanks, Liav.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:17>

Django

unread,
Apr 14, 2014, 4:30:41 PM4/14/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by bsilverberg):

I am going to start working on modeltests.basic.ModelTest.test_lookup

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:18>

Django

unread,
Apr 14, 2014, 6:24:39 PM4/14/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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 julien:

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.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.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:19>

Django

unread,
May 16, 2014, 5:17:35 AM5/16/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------

Comment (by zsoldosp):

I'm at the DjangoCon Europe Sprint and working on splitting up {{{
modeltests.basic.ModelTest.test_object_creation }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:20>

Django

unread,
May 16, 2014, 1:14:18 PM5/16/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by zsoldosp):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:21>

Django

unread,
May 16, 2014, 1:15:01 PM5/16/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by zsoldosp):

* cc: zsoldosp (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:22>

Django

unread,
May 20, 2014, 3:32:09 PM5/20/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by jose):

I have committed a pull request for the first reported unit test
`modeltests.generic_relations.GenericRelationsTests.test_generic_relations`.
You can check [https://github.com/django/django/pull/2693 the PR in
Github].

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:23>

Django

unread,
Jun 1, 2014, 12:37:11 PM6/1/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"7b064e539009b4845ca31bd4a3dd5a9b913d1a0e"]:
{{{
#!CommitTicketReference repository=""
revision="7b064e539009b4845ca31bd4a3dd5a9b913d1a0e"
Split GenericRelationsTests.test_generic_relations into several tests;
refs #18586.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:24>

Django

unread,
Jun 25, 2014, 3:41:29 PM6/25/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"7e2c804c9417617934cd731a4537719a1bd8d985"]:
{{{
#!CommitTicketReference repository=""
revision="7e2c804c9417617934cd731a4537719a1bd8d985"
Split tests.basic.ModelTests in several tests; refs #18586.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:25>

Django

unread,
Jun 25, 2014, 3:44:57 PM6/25/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: judy2k
Type: 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
--------------------------------------+------------------------------------
Changes (by timo):

* has_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:26>

Django

unread,
Jul 26, 2014, 10:05:54 AM7/26/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner:
Type: Cleanup/optimization | Status: new

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
--------------------------------------+------------------------------------
Changes (by timo):

* status: assigned => new
* owner: judy2k =>


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:27>

Django

unread,
Aug 8, 2014, 8:20:05 AM8/8/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by ChillarAnand):

* owner: => ChillarAnand


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:28>

Django

unread,
Sep 22, 2014, 9:11:27 AM9/22/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by davide-ceretti):

I am going to start working on M2mThroughTests

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:29>

Django

unread,
Sep 24, 2014, 6:43:23 PM9/24/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by davide-ceretti):

Patch for M2mThroughTests refactor is at
https://github.com/django/django/pull/3273

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:30>

Django

unread,
Sep 25, 2014, 5:55:00 AM9/25/14
to django-...@googlegroups.com
#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 davide-ceretti:

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]]

New description:

`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:31>

Django

unread,
Sep 25, 2014, 2:30:08 PM9/25/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by Loic Bistuer <loic.bistuer@…>):

In [changeset:"d8e157d5ab1648a509b25d5ec571572ae936de79"]:
{{{
#!CommitTicketReference repository=""
revision="d8e157d5ab1648a509b25d5ec571572ae936de79"
Refactored m2m_through tests. Refs #18586

Refactored old tests that were rewritten 1:1 from doctests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:32>

Django

unread,
Sep 25, 2014, 3:06:24 PM9/25/14
to django-...@googlegroups.com
#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 davide-ceretti:

Old description:

> There's quite a lot of unit tests that have been rewritten 1:1 from

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:33>

Django

unread,
Oct 4, 2014, 1:42:46 PM10/4/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by browniebroke):

Patch for ModelTest.test_lookup:
https://github.com/django/django/pull/3306

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:34>

Django

unread,
Oct 7, 2014, 12:05:18 PM10/7/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d1e87aebf70dd035c98a0b0f0162c0a2c398598c"]:
{{{
#!CommitTicketReference repository=""
revision="d1e87aebf70dd035c98a0b0f0162c0a2c398598c"
Refactored model lookup tests; refs #18586.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:35>

Django

unread,
Oct 8, 2014, 2:39:26 AM10/8/14
to django-...@googlegroups.com
#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]]

--

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:36>

Django

unread,
Nov 7, 2014, 12:00:31 PM11/7/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by agiliq):

Opened PR for custom pks here:
https://github.com/django/django/pull/3483

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:37>

Django

unread,
Nov 10, 2014, 6:34:33 AM11/10/14
to django-...@googlegroups.com
#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 agiliq:

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]]

New description:

~~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:38>

Django

unread,
Nov 10, 2014, 7:44:49 AM11/10/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by agiliq):

Opened PR for custom_managers here:
https://github.com/django/django/pull/3491

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:39>

Django

unread,
Nov 10, 2014, 7:51:04 AM11/10/14
to django-...@googlegroups.com
#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 agiliq:

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:40>

Django

unread,
Nov 21, 2014, 10:42:32 AM11/21/14
to django-...@googlegroups.com
#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 timgraham:

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:41>

Django

unread,
Nov 27, 2014, 5:29:19 PM11/27/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by helenst):

PR for order_with_respect_to:
https://github.com/django/django/pull/3638

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:42>

Django

unread,
Dec 1, 2014, 8:25:00 AM12/1/14
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by alexanderad):

PR for model_package.ModelPackageTests.test_models_packages:
https://github.com/django/django/pull/3657

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:43>

Django

unread,
Dec 1, 2014, 12:56:20 PM12/1/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

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
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"e1513a7960399054d6686efb287f3887ad84b73f"]:
{{{
#!CommitTicketReference repository=""
revision="e1513a7960399054d6686efb287f3887ad84b73f"
Fixed #18586 -- Split up model_package.ModelPackageTests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:44>

Django

unread,
Dec 1, 2014, 12:58:49 PM12/1/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new

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
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: closed => new
* resolution: fixed =>


Comment:

Woops, should have been "refs #" in the commit message of that last one so
this didn't get closed as there is still more work to do in the other
tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:45>

Django

unread,
Dec 2, 2014, 6:30:41 AM12/2/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by alexanderad):

PR for model_inheritance.ModelInheritanceTests
https://github.com/django/django/pull/3658.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:46>

Django

unread,
Dec 3, 2014, 6:55:10 PM12/3/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"2cd19f3738b9c4a6861c007bf22f72a386cba07f"]:
{{{
#!CommitTicketReference repository=""
revision="2cd19f3738b9c4a6861c007bf22f72a386cba07f"
Refs #18586 -- Split up model_inheritance.ModelInheritanceTest
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:47>

Django

unread,
Dec 3, 2014, 7:14:36 PM12/3/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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 timgraham:

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]]

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,
`tests.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:

~~tests.basic.ModelTest.test_lookup~~
~~tests.basic.ModelTest.test_object_creation~~
~~tests.custom_columns.CustomColumnsTests.test_db_column~~
~~tests.custom_managers.CustomManagerTests.test_manager~~
~~tests.custom_pk.CustomPKTests.test_custom_pk~~
`tests.defer.DeferTests.test_defer`
~~tests.expressions.ExpressionsTests.test_filter~~
~~tests.field_subclassing.CustomField.test_custom_field~~ (deprecated)
~~tests.get_or_create.GetOrCreateTests.test_get_or_create~~
~~tests.m2m_recursive.RecursiveM2MTests.test_recursive_m2m~~
`tests.m2m_signals.ManyToManySignalsTest`
~~tests.m2m_through.M2mThroughTests~~
`tests.m2m_through_regress.M2MThroughTestCase`
~~tests.model_inheritance.ModelInheritanceTests~~
~~tests.model_package.ModelPackageTests.test_model_packages~~
~~tests.order_with_respect_to.OrderWithRespectToTests.test_basic~~
~~tests.signals.SignalTests.test_basic~~

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:48>

Django

unread,
Dec 4, 2014, 6:40:28 AM12/4/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by berkerpeksag):

[https://github.com/django/django/pull/3638 PR #3638] LGTM. (I added a
couple of minor comments on GitHub)

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:49>

Django

unread,
Dec 4, 2014, 11:07:07 AM12/4/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"7daf00679d2848fdb6f5618009817b56486fce1b"]:
{{{
#!CommitTicketReference repository=""
revision="7daf00679d2848fdb6f5618009817b56486fce1b"
Refs #18586 -- Split up order_with_respect_to tests
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:50>

Django

unread,
Dec 11, 2014, 5:15:57 PM12/11/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"f66d9a2300f8fcb82d2bb21c43dc0e658c49086a"]:
{{{
#!CommitTicketReference repository=""
revision="f66d9a2300f8fcb82d2bb21c43dc0e658c49086a"
Refs #18586 -- Split custom_pk test.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:51>

Django

unread,
Dec 11, 2014, 5:48:08 PM12/11/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"6db122c7aba5738aad92aa20c9bbf2dea6d3308e"]:
{{{
#!CommitTicketReference repository=""
revision="6db122c7aba5738aad92aa20c9bbf2dea6d3308e"
Refs #18586 -- Split custom manager tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:52>

Django

unread,
Dec 11, 2014, 6:25:24 PM12/11/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"43041ee48c802418ec935a2ece59f876f5888c40"]:
{{{
#!CommitTicketReference repository=""
revision="43041ee48c802418ec935a2ece59f876f5888c40"
Refs #18586 -- Refactored expressions tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:53>

Django

unread,
Dec 18, 2014, 11:56:09 PM12/18/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by wearp):

I am going to start working on DeferTests.test_defer.

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:54>

Django

unread,
Dec 23, 2014, 6:55:36 PM12/23/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------
Changes (by AmiZya):

* cc: amizya@… (added)


Comment:

I'll work on `m2m_signals` and `m2m_through_regress`

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:55>

Django

unread,
Dec 31, 2014, 11:58:44 AM12/31/14
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"89527576980ff14309990c152e5904ddd5ca3df7"]:
{{{
#!CommitTicketReference repository=""
revision="89527576980ff14309990c152e5904ddd5ca3df7"
Refs #18586 -- Split up tests.defer.DeferTests.test_defer
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:56>

Django

unread,
Jan 1, 2015, 11:27:27 AM1/1/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | ChillarAnand
Cleanup/optimization | Status: new
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 wearp:

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,

New description:

~~tests.defer.DeferTests.test_defer~~


~~tests.expressions.ExpressionsTests.test_filter~~
~~tests.field_subclassing.CustomField.test_custom_field~~ (deprecated)
~~tests.get_or_create.GetOrCreateTests.test_get_or_create~~
~~tests.m2m_recursive.RecursiveM2MTests.test_recursive_m2m~~
`tests.m2m_signals.ManyToManySignalsTest`
~~tests.m2m_through.M2mThroughTests~~
`tests.m2m_through_regress.M2MThroughTestCase`
~~tests.model_inheritance.ModelInheritanceTests~~
~~tests.model_package.ModelPackageTests.test_model_packages~~
~~tests.order_with_respect_to.OrderWithRespectToTests.test_basic~~
~~tests.signals.SignalTests.test_basic~~

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:57>

Django

unread,
Mar 8, 2015, 7:34:40 AM3/8/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | alainivars
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
-------------------------------------+-------------------------------------
Changes (by alainivars):

* owner: ChillarAnand => alainivars
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:58>

Django

unread,
Mar 16, 2015, 1:17:56 PM3/16/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner:
Type: Cleanup/optimization | Status: new

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
--------------------------------------+------------------------------------
Changes (by timgraham):

* owner: alainivars =>
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:59>

Django

unread,
Mar 21, 2015, 2:40:21 PM3/21/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | alainivars
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
-------------------------------------+-------------------------------------
Changes (by alainivars):

* owner: => alainivars


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:60>

Django

unread,
Mar 22, 2015, 8:22:16 AM3/22/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | alainivars
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
-------------------------------------+-------------------------------------

Comment (by Baptiste Mispelon <bmispelon@…>):

In [changeset:"82ec05fcc96121d7b23cc07c2c0ad3c0546bac35" 82ec05f]:
{{{
#!CommitTicketReference repository=""
revision="82ec05fcc96121d7b23cc07c2c0ad3c0546bac35"
Refs #18586 -- Split up tests/m2m_signals
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:61>

Django

unread,
Mar 22, 2015, 8:26:36 AM3/22/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner:
Type: | alainivars
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 bmispelon:

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,
> `tests.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:
> ~~tests.basic.ModelTest.test_lookup~~
> ~~tests.basic.ModelTest.test_object_creation~~
> ~~tests.custom_columns.CustomColumnsTests.test_db_column~~
> ~~tests.custom_managers.CustomManagerTests.test_manager~~
> ~~tests.custom_pk.CustomPKTests.test_custom_pk~~

New description:

~~tests.m2m_signals.ManyToManySignalsTest~~


~~tests.m2m_through.M2mThroughTests~~
`tests.m2m_through_regress.M2MThroughTestCase`
~~tests.model_inheritance.ModelInheritanceTests~~
~~tests.model_package.ModelPackageTests.test_model_packages~~
~~tests.order_with_respect_to.OrderWithRespectToTests.test_basic~~
~~tests.signals.SignalTests.test_basic~~

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:62>

Django

unread,
Mar 22, 2015, 8:36:06 AM3/22/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner:
Type: Cleanup/optimization | Status: new
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
--------------------------------------+------------------------------------
Changes (by bmispelon):

* owner: alainivars =>
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:63>

Django

unread,
Mar 22, 2015, 10:42:47 AM3/22/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: exonian
Type: 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
--------------------------------------+------------------------------------
Changes (by exonian):

* status: new => assigned

* owner: => exonian


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:64>

Django

unread,
Mar 22, 2015, 12:05:23 PM3/22/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: exonian
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by exonian):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/4377

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:65>

Django

unread,
Mar 24, 2015, 12:54:46 PM3/24/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: exonian
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"8654c6a7329c06133b6c4b32f05e606132a338e5" 8654c6a7]:
{{{
#!CommitTicketReference repository=""
revision="8654c6a7329c06133b6c4b32f05e606132a338e5"
Refs #18586 -- Split up tests.m2m_through_regress
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:66>

Django

unread,
Mar 24, 2015, 12:58:26 PM3/24/15
to django-...@googlegroups.com
#18586: Rewrite unit tests migrated from doctests
--------------------------------------+------------------------------------
Reporter: koniiiik | Owner: exonian
Type: Cleanup/optimization | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: unit tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* status: assigned => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/18586#comment:67>

Reply all
Reply to author
Forward
0 new messages