summaryrefslogtreecommitdiff
path: root/tests/regressiontests/requests/tests.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-05-03 18:19:18 +0200
committerClaude Paroz <claude@2xlibre.net>2012-05-03 18:30:07 +0200
commit10cf3c64273db407402ea9723569dfc8d059e186 (patch)
tree09278a014019f628169ec4774a3ad6fb13650fb4 /tests/regressiontests/requests/tests.py
parente9a56606e738c478373d052bbd876ff84afdb995 (diff)
Used catch_warnings instead of save/restore methods. Refs #17049.
Diffstat (limited to 'tests/regressiontests/requests/tests.py')
-rw-r--r--tests/regressiontests/requests/tests.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
index c838832b25..d1c0896720 100644
--- a/tests/regressiontests/requests/tests.py
+++ b/tests/regressiontests/requests/tests.py
@@ -6,7 +6,6 @@ from StringIO import StringIO
from django.conf import settings
from django.core.handlers.wsgi import WSGIRequest, LimitedStream
from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_repr, UnreadablePostError
-from django.test.utils import get_warnings_state, restore_warnings_state
from django.utils import unittest
from django.utils.http import cookie_date
from django.utils.timezone import utc
@@ -398,13 +397,9 @@ class RequestsTests(unittest.TestCase):
'wsgi.input': StringIO(payload)
})
- warnings_state = get_warnings_state()
- warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.http')
- try:
+ with warnings.catch_warnings(record=True) as w:
self.assertEqual(request.body, request.raw_post_data)
- finally:
- restore_warnings_state(warnings_state)
-
+ self.assertEqual(len(w), 1)
def test_POST_connection_error(self):
"""
@@ -420,10 +415,7 @@ class RequestsTests(unittest.TestCase):
'CONTENT_LENGTH': len(payload),
'wsgi.input': ExplodingStringIO(payload)})
- warnings_state = get_warnings_state()
- warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.http')
- try:
+ with warnings.catch_warnings(record=True) as w:
with self.assertRaises(UnreadablePostError):
request.raw_post_data
- finally:
- restore_warnings_state(warnings_state)
+ self.assertEqual(len(w), 1)