Opened 17 months ago

Closed 15 months ago

Last modified 15 months ago

#22102 closed Bug (fixed)

Wrong test ordering

Reported by: aptiko 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 16 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 15 months ago by claudep

  • Has patch set

comment:3 Changed 15 months ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 15 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

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 15 months 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