diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-05-03 20:18:05 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-05-03 20:18:05 +0200 |
| commit | 00c0d3c44ebc4e3461653ec96cd47023cc0a6e5b (patch) | |
| tree | 050b07dde4949a585f59572eaa1d79d4c3427064 /tests | |
| parent | 10cf3c64273db407402ea9723569dfc8d059e186 (diff) | |
Made warning assertions work with or without -Wall python switch
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/cache/tests.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/decorators/tests.py | 3 | ||||
| -rw-r--r-- | tests/regressiontests/requests/tests.py | 3 | ||||
| -rw-r--r-- | tests/regressiontests/utils/text.py | 4 |
4 files changed, 6 insertions, 6 deletions
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py index f0e2977b31..780718b487 100644 --- a/tests/regressiontests/cache/tests.py +++ b/tests/regressiontests/cache/tests.py @@ -469,11 +469,13 @@ class BaseCacheTests(object): try: with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") # memcached does not allow whitespace or control characters in keys self.cache.set('key with spaces', 'value') self.assertEqual(len(w), 2) self.assertTrue(isinstance(w[0].message, CacheKeyWarning)) with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") # memcached limits key length to 250 self.cache.set('a' * 251, 'value') self.assertEqual(len(w), 1) diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py index 975502273a..0c5b2e97da 100644 --- a/tests/regressiontests/decorators/tests.py +++ b/tests/regressiontests/decorators/tests.py @@ -122,7 +122,7 @@ class DecoratorsTest(TestCase): """ def my_view(request): return "response" - with warnings.catch_warnings(record=True) as w: + with warnings.catch_warnings(record=True): my_view_cached = cache_page(my_view, 123) self.assertEqual(my_view_cached(HttpRequest()), "response") my_view_cached2 = cache_page(my_view, 123, key_prefix="test") @@ -131,7 +131,6 @@ class DecoratorsTest(TestCase): self.assertEqual(my_view_cached3(HttpRequest()), "response") my_view_cached4 = cache_page()(my_view) self.assertEqual(my_view_cached4(HttpRequest()), "response") - self.assertEqual(len(w), 4) def test_require_safe_accepts_only_safe_methods(self): """ diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py index d1c0896720..cf4c58b1f9 100644 --- a/tests/regressiontests/requests/tests.py +++ b/tests/regressiontests/requests/tests.py @@ -397,9 +397,8 @@ class RequestsTests(unittest.TestCase): 'wsgi.input': StringIO(payload) }) - with warnings.catch_warnings(record=True) as w: + with warnings.catch_warnings(record=True): self.assertEqual(request.body, request.raw_post_data) - self.assertEqual(len(w), 1) def test_POST_connection_error(self): """ diff --git a/tests/regressiontests/utils/text.py b/tests/regressiontests/utils/text.py index 6457845c6f..e749ccfbe6 100644 --- a/tests/regressiontests/utils/text.py +++ b/tests/regressiontests/utils/text.py @@ -79,7 +79,7 @@ class TestUtilsText(SimpleTestCase): text.truncate_words('The quick brown fox jumped over the lazy dog.', 4)) self.assertEqual(u'The quick brown fox ....', text.truncate_words('The quick brown fox jumped over the lazy dog.', 4, '....')) - self.assertEqual(len(w), 3) + self.assertGreater(len(w), 0) def test_old_truncate_html_words(self): with warnings.catch_warnings(record=True) as w: @@ -91,7 +91,7 @@ class TestUtilsText(SimpleTestCase): text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, '....')) self.assertEqual(u'<p><strong><em>The quick brown fox</em></strong></p>', text.truncate_html_words('<p><strong><em>The quick brown fox jumped over the lazy dog.</em></strong></p>', 4, None)) - self.assertEqual(len(w), 4) + self.assertGreater(len(w), 0) def test_wrap(self): digits = '1234 67 9' |
