Commit e4ee3d8f authored by Florian Apolloner's avatar Florian Apolloner
Browse files

Fixed a few ResourceWarnings.

parent e4e12875
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -108,14 +108,12 @@ class FileStorageTests(TestCase):
        temp_storage.save('tests/example.txt', ContentFile('some content'))

        # Load it as python file object
        file_obj = open(temp_storage.path('tests/example.txt'))

        with open(temp_storage.path('tests/example.txt')) as file_obj:
            # Save it using storage and read its content
            temp_storage.save('tests/file_obj', file_obj)
        self.assertTrue(temp_storage.exists('tests/file_obj'))
        self.assertEqual(
            temp_storage.open('tests/file_obj').read(),
            b'some content')
        with temp_storage.open('tests/file_obj') as f:
            self.assertEqual(f.read(), b'some content')


    def test_stringio(self):
@@ -127,9 +125,8 @@ class FileStorageTests(TestCase):
        # Save it and read written file
        temp_storage.save('tests/stringio', output)
        self.assertTrue(temp_storage.exists('tests/stringio'))
        self.assertEqual(
            temp_storage.open('tests/stringio').read(),
            b'content')
        with temp_storage.open('tests/stringio') as f:
            self.assertEqual(f.read(), b'content')



+2 −2
Original line number Diff line number Diff line
@@ -639,7 +639,7 @@ class FileLikeObjectTestCase(LiveServerBase):
        f = File(file_like_object)
        stored_filename = self.storage.save("remote_file.html", f)

        stored_file = self.storage.open(stored_filename)
        remote_file = self.urlopen('/example_view/')

        with self.storage.open(stored_filename) as stored_file:
            self.assertEqual(stored_file.read(), remote_file.read())
+0 −1
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ import shutil
import subprocess
import sys
import tempfile
import warnings

from django import contrib
from django.utils._os import upath