Opened 11 years ago

Closed 11 years ago

#20789 closed Bug (invalid)

Inconsistent imports for Django Testcase

Reported by: graham.klyne@… Owned by: nobody
Component: Documentation Version: 1.5
Severity: Normal Keywords: Testcase import
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the documentation page at: https://docs.djangoproject.com/en/1.5/topics/testing/overview/

The 'unittest2' box at the top of the page has:

from django.utils import unittest

But in the first example below this we have:

from django.test import TestCase

I note the generated test.py has the latter form of import.

I assume one of these is wrong, probably the first?

#g

Change History (1)

comment:1 by Russell Keith-Magee, 11 years ago

Resolution: invalid
Status: newclosed

The two imports are different.

django.utils.unittest.TestCase is Django's packaged copy of unittest2. We've included this package because historically, Python's packaging tools haven't been good with dependencies, and we wanted to ensure every user had a good out-of-the-box experience. When we drop Python 2.6 as a dependency, we'll be able to deprecate this packaging choice, as unittest2 is available by default on Python 2.7+.

django.test.TestCase is a Django's TestCase. It's a subclass of unittest.TestCase, and adds additional functionality specific to testing Django.

So - neither import is wrong, or inconsistent - they're pointing at different objects.

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