Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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:

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"

Attachments (0)

Change History (4)

comment:1 Changed 3 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 3 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 3 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 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.