Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15364 -- Ensure files are closed correctly during file tests. …

…Thanks to Mila for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15604 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b700c3a918a03ea0aa4fd16690af82c21813a6ae 1 parent f21fc71
Russell Keith-Magee authored February 21, 2011

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
@@ -30,6 +30,7 @@ def test_files(self):
30 30
         self.assertEqual(obj1.normal.name, "tests/django_test.txt")
31 31
         self.assertEqual(obj1.normal.size, 7)
32 32
         self.assertEqual(obj1.normal.read(), "content")
  33
+        obj1.normal.close()
33 34
 
34 35
         # File objects can be assigned to FileField attributes, but shouldn't
35 36
         # get committed until the model it's attached to is saved.
@@ -49,6 +50,7 @@ def test_files(self):
49 50
         self.assertEqual(obj1.normal.read(3), "con")
50 51
         self.assertEqual(obj1.normal.read(), "tent")
51 52
         self.assertEqual(list(obj1.normal.chunks(chunk_size=2)), ["co", "nt", "en", "t"])
  53
+        obj1.normal.close()
52 54
 
53 55
         # Save another file with the same name.
54 56
         obj2 = Storage()
@@ -81,12 +83,14 @@ def test_files(self):
81 83
         obj3 = Storage.objects.create()
82 84
         self.assertEqual(obj3.default.name, "tests/default.txt")
83 85
         self.assertEqual(obj3.default.read(), "default content")
  86
+        obj3.default.close()
84 87
 
85 88
         # But it shouldn't be deleted, even if there are no more objects using
86 89
         # it.
87 90
         obj3.delete()
88 91
         obj3 = Storage()
89 92
         self.assertEqual(obj3.default.read(), "default content")
  93
+        obj3.default.close()
90 94
 
91 95
         # Verify the fix for #5655, making sure the directory is only
92 96
         # determined once.

0 notes on commit b700c3a

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