summaryrefslogtreecommitdiff
path: root/tests/servers
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-01-19 08:50:28 -0500
committerGitHub <noreply@github.com>2017-01-19 08:50:28 -0500
commit5320fa77c3b2bc02ac232c3e0f5279d99a528e6a (patch)
tree34da130e2b96cdedecff09122e20362f312a1b28 /tests/servers
parent7d200949968002d2c2b4390953e8bda7153a49c9 (diff)
downloaddjango-5320fa77c3b2bc02ac232c3e0f5279d99a528e6a.tar.gz
Refs #23919 -- Removed obsolete contextlib.closing() calls (for Python 2).
Diffstat (limited to 'tests/servers')
-rw-r--r--tests/servers/tests.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/servers/tests.py b/tests/servers/tests.py
index 8f7e3253e7..bf87306cce 100644
--- a/tests/servers/tests.py
+++ b/tests/servers/tests.py
@@ -1,7 +1,6 @@
"""
Tests for django.core.servers.
"""
-import contextlib
import errno
import os
import socket
@@ -58,11 +57,11 @@ class LiveServerViews(LiveServerBase):
self.assertEqual(err.exception.code, 404, 'Expected 404 response')
def test_view(self):
- with contextlib.closing(self.urlopen('/example_view/')) as f:
+ with self.urlopen('/example_view/') as f:
self.assertEqual(f.read(), b'example view')
def test_static_files(self):
- with contextlib.closing(self.urlopen('/static/example_static_file.txt')) as f:
+ with self.urlopen('/static/example_static_file.txt') as f:
self.assertEqual(f.read().rstrip(b'\r\n'), b'example static file')
def test_no_collectstatic_emulation(self):
@@ -76,11 +75,11 @@ class LiveServerViews(LiveServerBase):
self.assertEqual(err.exception.code, 404, 'Expected 404 response')
def test_media_files(self):
- with contextlib.closing(self.urlopen('/media/example_media_file.txt')) as f:
+ with self.urlopen('/media/example_media_file.txt') as f:
self.assertEqual(f.read().rstrip(b'\r\n'), b'example media file')
def test_environ(self):
- with contextlib.closing(self.urlopen('/environ_view/?%s' % urlencode({'q': 'тест'}))) as f:
+ with self.urlopen('/environ_view/?%s' % urlencode({'q': 'тест'})) as f:
self.assertIn(b"QUERY_STRING: 'q=%D1%82%D0%B5%D1%81%D1%82'", f.read())
@@ -90,7 +89,7 @@ class LiveServerDatabase(LiveServerBase):
"""
Fixtures are properly loaded and visible to the live server thread.
"""
- with contextlib.closing(self.urlopen('/model_view/')) as f:
+ with self.urlopen('/model_view/') as f:
self.assertEqual(f.read().splitlines(), [b'jane', b'robert'])
def test_database_writes(self):