Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Made warning assertions work with or without -Wall python switch

  • Loading branch information...
commit 00c0d3c44ebc4e3461653ec96cd47023cc0a6e5b 1 parent 10cf3c6
Claude Paroz authored May 03, 2012
1  django/contrib/sessions/tests.py
@@ -302,6 +302,7 @@ def test_exists_searches_cache_first(self):
302 302
 
303 303
     def test_load_overlong_key(self):
304 304
         with warnings.catch_warnings(record=True) as w:
  305
+            warnings.simplefilter("always")
305 306
             self.session._session_key = (string.ascii_letters + string.digits) * 20
306 307
             self.assertEqual(self.session.load(), {})
307 308
             self.assertEqual(len(w), 1)
2  tests/regressiontests/cache/tests.py
@@ -469,11 +469,13 @@ def func(key, *args):
469 469
 
470 470
         try:
471 471
             with warnings.catch_warnings(record=True) as w:
  472
+                warnings.simplefilter("always")
472 473
                 # memcached does not allow whitespace or control characters in keys
473 474
                 self.cache.set('key with spaces', 'value')
474 475
                 self.assertEqual(len(w), 2)
475 476
                 self.assertTrue(isinstance(w[0].message, CacheKeyWarning))
476 477
             with warnings.catch_warnings(record=True) as w:
  478
+                warnings.simplefilter("always")
477 479
                 # memcached limits key length to 250
478 480
                 self.cache.set('a' * 251, 'value')
479 481
                 self.assertEqual(len(w), 1)
3  tests/regressiontests/decorators/tests.py
@@ -122,7 +122,7 @@ def test_cache_page_old_style(self):
122 122
         """
123 123
         def my_view(request):
124 124
             return "response"
125  
-        with warnings.catch_warnings(record=True) as w:
  125
+        with warnings.catch_warnings(record=True):
126 126
             my_view_cached = cache_page(my_view, 123)
127 127
             self.assertEqual(my_view_cached(HttpRequest()), "response")
128 128
             my_view_cached2 = cache_page(my_view, 123, key_prefix="test")
@@ -131,7 +131,6 @@ def my_view(request):
131 131
             self.assertEqual(my_view_cached3(HttpRequest()), "response")
132 132
             my_view_cached4 = cache_page()(my_view)
133 133
             self.assertEqual(my_view_cached4(HttpRequest()), "response")
134  
-            self.assertEqual(len(w), 4)
135 134
 
136 135
     def test_require_safe_accepts_only_safe_methods(self):
137 136
         """
3  tests/regressiontests/requests/tests.py
@@ -397,9 +397,8 @@ def test_raw_post_data_returns_body(self):
397 397
             'wsgi.input': StringIO(payload)
398 398
         })
399 399
 
400  
-        with warnings.catch_warnings(record=True) as w:
  400
+        with warnings.catch_warnings(record=True):
401 401
             self.assertEqual(request.body, request.raw_post_data)
402  
-            self.assertEqual(len(w), 1)
403 402
 
404 403
     def test_POST_connection_error(self):
405 404
         """
4  tests/regressiontests/utils/text.py
@@ -79,7 +79,7 @@ def test_old_truncate_words(self):
79 79
                 text.truncate_words('The quick brown fox jumped over the lazy dog.', 4))
80 80
             self.assertEqual(u'The quick brown fox ....',
81 81
                 text.truncate_words('The quick brown fox jumped over the lazy dog.', 4, '....'))
82  
-            self.assertEqual(len(w), 3)
  82
+            self.assertGreater(len(w), 0)
83 83
 
84 84
     def test_old_truncate_html_words(self):
85 85
         with warnings.catch_warnings(record=True) as w:
@@ -91,7 +91,7 @@ def test_old_truncate_html_words(self):
91 91
                 text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, '....'))
92 92
             self.assertEqual(u'<p><strong><em>The quick brown fox</em></strong></p>',
93 93
                 text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, None))
94  
-            self.assertEqual(len(w), 4)
  94
+            self.assertGreater(len(w), 0)
95 95
 
96 96
     def test_wrap(self):
97 97
         digits = '1234 67 9'

0 notes on commit 00c0d3c

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