Code

Opened 6 years ago

Closed 6 years ago

#5995 closed (worksforme)

assertContains() - AttributeError

Reported by: b23dev@… Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords: test, assertContains
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I get a AttributeError when I try the django test client method assertContains():
(found assertContains() in the documentation, http://www.djangoproject.com/documentation/testing/)

class TestUsers(unittest.TestCase):

    def setUp(self):
        self.client = Client()

    def testUsername(self):
        response = self.client.get('/username/')
        self.assertContains(response, "actionjakson", count=None, status_code=200)


i got this traceback:

Traceback (most recent call last):
  File "/home/src/vp/../vp/portal/tests.py", line 49, in testUsername
    self.assertContains(response, "actionjakson", count=None, status_code=200)
AttributeError: 'TestUsers' object has no attribute 'assertContains'


I'm using a fresh django svn checkout.

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by mattmcc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

assertContains is a method added by Django's TestCase class, which subclasses the standard Python unittest.TestCase. Your test case is extending the standard Python TestCase rather than Django's.

See: http://www.djangoproject.com/documentation/testing/#testcase

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.