Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #15364 -- Ensure files are closed correctly during file…

… tests. Thanks to Mila for the report and patch.

Backport of r15604 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15608 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit bf4507f255f7fb2e162fbe5b228ef3f380f223ed 1 parent e636db1
Russell Keith-Magee authored

Showing 1 changed file with 4 additions and 0 deletions. Show diff stats Hide diff stats

  1. 4  tests/modeltests/files/tests.py
4  tests/modeltests/files/tests.py
@@ -27,6 +27,7 @@ def test_files(self):
27 27
         self.assertEqual(obj1.normal.name, "tests/django_test.txt")
28 28
         self.assertEqual(obj1.normal.size, 7)
29 29
         self.assertEqual(obj1.normal.read(), "content")
  30
+        obj1.normal.close()
30 31
 
31 32
         # File objects can be assigned to FileField attributes, but shouldn't
32 33
         # get committed until the model it's attached to is saved.
@@ -46,6 +47,7 @@ def test_files(self):
46 47
         self.assertEqual(obj1.normal.read(3), "con")
47 48
         self.assertEqual(obj1.normal.read(), "tent")
48 49
         self.assertEqual(list(obj1.normal.chunks(chunk_size=2)), ["co", "nt", "en", "t"])
  50
+        obj1.normal.close()
49 51
 
50 52
         # Save another file with the same name.
51 53
         obj2 = Storage()
@@ -78,12 +80,14 @@ def test_files(self):
78 80
         obj3 = Storage.objects.create()
79 81
         self.assertEqual(obj3.default.name, "tests/default.txt")
80 82
         self.assertEqual(obj3.default.read(), "default content")
  83
+        obj3.default.close()
81 84
 
82 85
         # But it shouldn't be deleted, even if there are no more objects using
83 86
         # it.
84 87
         obj3.delete()
85 88
         obj3 = Storage()
86 89
         self.assertEqual(obj3.default.read(), "default content")
  90
+        obj3.default.close()
87 91
 
88 92
         # Verify the fix for #5655, making sure the directory is only
89 93
         # determined once.

0 notes on commit bf4507f

Please sign in to comment.
Something went wrong with that request. Please try again.