Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13615 -- Clarified test assertion text to avoid confusion when…

… response content isn't a web page. Thanks to DaNmarner for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13512 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9767993a245bd465d64e7bc50d5c4b72eee5b8ef 1 parent 0c37f8d
Russell Keith-Magee authored August 06, 2010
8  django/test/testcases.py
@@ -347,7 +347,7 @@ def assertRedirects(self, response, expected_url, status_code=302,
347 347
     def assertContains(self, response, text, count=None, status_code=200,
348 348
                        msg_prefix=''):
349 349
         """
350  
-        Asserts that a response indicates that a page was retrieved
  350
+        Asserts that a response indicates that some content was retrieved
351 351
         successfully, (i.e., the HTTP status code was as expected), and that
352 352
         ``text`` occurs ``count`` times in the content of the response.
353 353
         If ``count`` is None, the count doesn't matter - the assertion is true
@@ -357,7 +357,7 @@ def assertContains(self, response, text, count=None, status_code=200,
357 357
             msg_prefix += ": "
358 358
 
359 359
         self.assertEqual(response.status_code, status_code,
360  
-            msg_prefix + "Couldn't retrieve page: Response code was %d"
  360
+            msg_prefix + "Couldn't retrieve content: Response code was %d"
361 361
             " (expected %d)" % (response.status_code, status_code))
362 362
         text = smart_str(text, response._charset)
363 363
         real_count = response.content.count(text)
@@ -372,7 +372,7 @@ def assertContains(self, response, text, count=None, status_code=200,
372 372
     def assertNotContains(self, response, text, status_code=200,
373 373
                           msg_prefix=''):
374 374
         """
375  
-        Asserts that a response indicates that a page was retrieved
  375
+        Asserts that a response indicates that some content was retrieved
376 376
         successfully, (i.e., the HTTP status code was as expected), and that
377 377
         ``text`` doesn't occurs in the content of the response.
378 378
         """
@@ -380,7 +380,7 @@ def assertNotContains(self, response, text, status_code=200,
380 380
             msg_prefix += ": "
381 381
 
382 382
         self.assertEqual(response.status_code, status_code,
383  
-            msg_prefix + "Couldn't retrieve page: Response code was %d"
  383
+            msg_prefix + "Couldn't retrieve content: Response code was %d"
384 384
             " (expected %d)" % (response.status_code, status_code))
385 385
         text = smart_str(text, response._charset)
386 386
         self.assertEqual(response.content.count(text), 0,
8  tests/regressiontests/test_client_regress/models.py
@@ -34,20 +34,20 @@ def test_contains(self):
34 34
         try:
35 35
             self.assertContains(response, 'text', status_code=999)
36 36
         except AssertionError, e:
37  
-            self.assertEquals(str(e), "Couldn't retrieve page: Response code was 200 (expected 999)")
  37
+            self.assertEquals(str(e), "Couldn't retrieve content: Response code was 200 (expected 999)")
38 38
         try:
39 39
             self.assertContains(response, 'text', status_code=999, msg_prefix='abc')
40 40
         except AssertionError, e:
41  
-            self.assertEquals(str(e), "abc: Couldn't retrieve page: Response code was 200 (expected 999)")
  41
+            self.assertEquals(str(e), "abc: Couldn't retrieve content: Response code was 200 (expected 999)")
42 42
 
43 43
         try:
44 44
             self.assertNotContains(response, 'text', status_code=999)
45 45
         except AssertionError, e:
46  
-            self.assertEquals(str(e), "Couldn't retrieve page: Response code was 200 (expected 999)")
  46
+            self.assertEquals(str(e), "Couldn't retrieve content: Response code was 200 (expected 999)")
47 47
         try:
48 48
             self.assertNotContains(response, 'text', status_code=999, msg_prefix='abc')
49 49
         except AssertionError, e:
50  
-            self.assertEquals(str(e), "abc: Couldn't retrieve page: Response code was 200 (expected 999)")
  50
+            self.assertEquals(str(e), "abc: Couldn't retrieve content: Response code was 200 (expected 999)")
51 51
 
52 52
         try:
53 53
             self.assertNotContains(response, 'once')

0 notes on commit 9767993

Please sign in to comment.
Something went wrong with that request. Please try again.