Opened 6 years ago

Closed 4 years ago

#15896 closed Bug (wontfix)

unittest docs say import django.utils, should be djanto.test

Reported by: Roy Smith Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


At, it says:

from django.utils import unittest

It should import from django.test, no? It's wrong in the release notes too. The sample file gets it right.

Change History (5)

comment:1 Changed 6 years ago by Jonas H.

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: invalid
Status: newclosed

Ever tried to do so?

>>> from django.test import unittest
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
ImportError: cannot import name unittest

comment:2 Changed 6 years ago by Roy Smith

Resolution: invalid
Status: closedreopened

Hmm, OK, I read this a little more carefully and see what had me going. The docs say:

from django.utils import unittest

but the sample file says:

from django.test import TestCase

this is a little confusing. It would be more obvious if the sample and the docs did it the same way.

comment:3 Changed 6 years ago by Jonas H.

Resolution: invalid
Status: reopenedclosed

It's a different thing. django.utils.unittest is a copy of the unittest2 package for Python < 2.7. django.test holds Django's special testsuite helpers.

In most cases you don't need to import anything from django.utils.unittest. It's just some kind of warning to prevent you from using import unittest.

comment:4 Changed 4 years ago by tuomas.salo@…

Resolution: invalid
Status: closednew
UI/UX: unset

A problem persists. The docs start by samples with from django.utils import unittest, but the example created by python startapp says from django.test import TestCase. That might confuse people starting to write tests. The docs do mention something about the difference, but only after a few pagefuls.

comment:5 Changed 4 years ago by Jacob

Resolution: wontfix
Status: newclosed

They really are two different things, used for two different purposes. I'm going to close this again; if you feel strongly, please take it to django-dev for discussion.

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