Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15285 closed (fixed)

Example in Topic/Testing refer to django.utils.unittest

Reported by: kamal.mustafa@… Owned by: Gabriel Hurley
Component: Documentation Version: 1.2
Severity: Keywords: testing
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I'm reading and there's example:-

from django.utils import unittest
from myapp.models import Animal

class AnimalTestCase(unittest.TestCase):
    def setUp(self):
        self.lion = Animal.objects.create(name="lion", sound="roar") = Animal.objects.create(name="cat", sound="meow")

    def testSpeaking(self):
        self.assertEqual(self.lion.speak(), 'The lion says "roar"')
        self.assertEqual(, 'The cat says "meow"')

And this is how I installed Django:-

$ mkvirtualenv testdjango
$ pip install Django==1.2
$ python
>>> import django
>>> django.get_version()
>>> import django.utils.unittest
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named unittest
>>> from django.utils import unittest
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: cannot import name unittest

Got the same result with "pip install Django==1.2.4"

Change History (4)

comment:1 Changed 7 years ago by Łukasz Rekucki

Triage Stage: UnreviewedAccepted

This is an error in the docs.

comment:2 Changed 7 years ago by Gabriel Hurley

milestone: 1.3
Owner: changed from nobody to Gabriel Hurley
Status: newassigned

Yep, that was backported from trunk [15228], and didn't get edited for 1.2.X. It's an easy fix.

comment:3 Changed 7 years ago by Gabriel Hurley

Resolution: fixed
Status: assignedclosed

In [15543]:

[1.2.X] Fixed #15285 -- Corrected an erroneous import statement in the testing docs. Thanks to kamal.mustafa for the report.

comment:4 Changed 7 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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