Opened 13 years ago

Closed 13 years ago

Last modified 12 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: no UI/UX: no

Description

I'm reading http://docs.djangoproject.com/en/1.2/topics/testing/ 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")
        self.cat = Animal.objects.create(name="cat", sound="meow")

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

And this is how I installed Django:-

$ mkvirtualenv testdjango
$ pip install Django==1.2
$ python
>>> import django
>>> django.get_version()
'1.2'
>>> 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 by Łukasz Rekucki, 13 years ago

Triage Stage: UnreviewedAccepted

This is an error in the docs.

comment:2 by Gabriel Hurley, 13 years ago

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 by Gabriel Hurley, 13 years ago

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 by Jacob, 12 years ago

milestone: 1.3

Milestone 1.3 deleted

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