Opened 17 years ago

Closed 17 years ago

#5995 closed (worksforme)

assertContains() - AttributeError

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

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.

Change History (1)

comment:1 by Matt McClanahan, 17 years ago

Resolution: worksforme
Status: newclosed

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

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