diff options
Diffstat (limited to 'tests/staticfiles_tests/test_liveserver.py')
| -rw-r--r-- | tests/staticfiles_tests/test_liveserver.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/staticfiles_tests/test_liveserver.py b/tests/staticfiles_tests/test_liveserver.py index b6dfc767e7..72dee8999c 100644 --- a/tests/staticfiles_tests/test_liveserver.py +++ b/tests/staticfiles_tests/test_liveserver.py @@ -4,6 +4,7 @@ django.contrib.staticfiles.testing.StaticLiveServerTestCase instead of django.test.LiveServerTestCase. """ +import contextlib import os from django.contrib.staticfiles.testing import StaticLiveServerTestCase @@ -94,5 +95,5 @@ class StaticLiveServerView(LiveServerBase): Test that StaticLiveServerTestCase use of staticfiles' serve() allows it to discover app's static assets without having to collectstatic first. """ - f = self.urlopen('/static/test/file.txt') - self.assertEqual(f.read().rstrip(b'\r\n'), b'In static directory.') + with contextlib.closing(self.urlopen('/static/test/file.txt')) as f: + self.assertEqual(f.read().rstrip(b'\r\n'), b'In static directory.') |
