Ticket #15364: FileTests.diff

File FileTests.diff, 1.5 KB (added by Miloslav Pojman, 14 years ago)
  • tests/modeltests/files/tests.py

    diff --git a/tests/modeltests/files/tests.py b/tests/modeltests/files/tests.py
    index ad5c3a7..fce3b4d 100644
    a b class FileTests(TestCase):  
    3030        self.assertEqual(obj1.normal.name, "tests/django_test.txt")
    3131        self.assertEqual(obj1.normal.size, 7)
    3232        self.assertEqual(obj1.normal.read(), "content")
     33        obj1.normal.close()
    3334
    3435        # File objects can be assigned to FileField attributes, but shouldn't
    3536        # get committed until the model it's attached to is saved.
    class FileTests(TestCase):  
    4950        self.assertEqual(obj1.normal.read(3), "con")
    5051        self.assertEqual(obj1.normal.read(), "tent")
    5152        self.assertEqual(list(obj1.normal.chunks(chunk_size=2)), ["co", "nt", "en", "t"])
     53        obj1.normal.close()
    5254
    5355        # Save another file with the same name.
    5456        obj2 = Storage()
    class FileTests(TestCase):  
    8183        obj3 = Storage.objects.create()
    8284        self.assertEqual(obj3.default.name, "tests/default.txt")
    8385        self.assertEqual(obj3.default.read(), "default content")
     86        obj3.default.close()
    8487
    8588        # But it shouldn't be deleted, even if there are no more objects using
    8689        # it.
    8790        obj3.delete()
    8891        obj3 = Storage()
    8992        self.assertEqual(obj3.default.read(), "default content")
     93        obj3.default.close()
    9094
    9195        # Verify the fix for #5655, making sure the directory is only
    9296        # determined once.
Back to Top