Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#15285 closed (fixed)

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

Reported by: kamal.mustafa@… Owned by: gabrielhurley
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 5 years ago by lrekucki

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

This is an error in the docs.

comment:2 Changed 5 years ago by gabrielhurley

  • milestone set to 1.3
  • Owner changed from nobody to gabrielhurley
  • Status changed from new to assigned

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

comment:3 Changed 5 years ago by gabrielhurley

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

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 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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