1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed ResourceWarnings in tests/servers/tests.py.

e.g. ResourceWarning: unclosed <socket.socket [closed] fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
This commit is contained in:
Jon Dufresne
2017-06-05 06:56:51 -07:00
committed by Tim Graham
parent ed244199c7
commit a0f8c52ae2
2 changed files with 10 additions and 6 deletions

View File

@@ -69,6 +69,7 @@ class LiveServerViews(LiveServerBase):
def test_404(self):
with self.assertRaises(HTTPError) as err:
self.urlopen('/')
err.exception.close()
self.assertEqual(err.exception.code, 404, 'Expected 404 response')
def test_view(self):
@@ -87,6 +88,7 @@ class LiveServerViews(LiveServerBase):
"""
with self.assertRaises(HTTPError) as err:
self.urlopen('/static/another_app/another_app_static_file.txt')
err.exception.close()
self.assertEqual(err.exception.code, 404, 'Expected 404 response')
def test_media_files(self):
@@ -111,7 +113,8 @@ class LiveServerDatabase(LiveServerBase):
"""
Data written to the database by a view can be read.
"""
self.urlopen('/create_model_instance/')
with self.urlopen('/create_model_instance/'):
pass
self.assertQuerysetEqual(
Person.objects.all().order_by('pk'),
['jane', 'robert', 'emily'],