Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#22102 closed Bug (fixed)

Wrong test ordering

Reported by: Antonis Christofides Owned by: nobody
Component: Testing framework Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

According to the documentation, the order of test execution is first (1) django.test.TestCase subclasses, then (2) "all other unittests (including unittest.TestCase, ...)", then (3) doctests. However, doctest.DocTestCase is a subclass of unittest.TestCase. Therefore the documentation is inaccurate: it implies that doctests do not descend from unittest.TestCase.

The django.test.runner has this:

    reorder_by = (TestCase, )

where TestCase is actually django.test.TestCase. Therefore, in contrast to the documentation, no other unittest.TestCase subclasses seem to be taken into account. Indeed, I'm debugging an application in which some doctests insist running before some LiveServerTestCase tests; the problem goes away if I use a django.test.runner.DiscoverRunner subclass that has

    reorder_by = (django.test.TestCase, django.test.SimpleTestCase)

Change History (5)

comment:1 Changed 3 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:2 Changed 3 years ago by Claude Paroz

Has patch: set

comment:3 Changed 3 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:4 Changed 3 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In 3e3a7372f58e005813dd1b9e61eb85a5e43c7173:

Fixed #22102 -- Made SimpleTestCase tests run before unittest.TestCase ones

Thanks aptiko for the reporti and Tim Graham for the review.

comment:5 Changed 3 years ago by Claude Paroz <claude@…>

In d9f8cc12aeeb5309139a79d9b613fa405ebed36e:

[1.7.x] Fixed #22102 -- Made SimpleTestCase tests run before unittest.TestCase ones

Thanks aptiko for the report and Tim Graham for the review.
Backport of 3e3a7372f5 from master.

Note: See TracTickets for help on using tickets.
Back to Top