diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-21 14:06:12 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-21 14:06:12 +0000 |
| commit | bf4507f255f7fb2e162fbe5b228ef3f380f223ed (patch) | |
| tree | 250da67bc7ebb41535e96f117337a9534abf2707 | |
| parent | e636db10662e64ddc4156c3a3c8a40d4fe71a7a7 (diff) | |
[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
| -rw-r--r-- | tests/modeltests/files/tests.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/modeltests/files/tests.py b/tests/modeltests/files/tests.py index 6348d022e2..404aa48ddb 100644 --- a/tests/modeltests/files/tests.py +++ b/tests/modeltests/files/tests.py @@ -27,6 +27,7 @@ class FileTests(TestCase): self.assertEqual(obj1.normal.name, "tests/django_test.txt") self.assertEqual(obj1.normal.size, 7) self.assertEqual(obj1.normal.read(), "content") + obj1.normal.close() # File objects can be assigned to FileField attributes, but shouldn't # get committed until the model it's attached to is saved. @@ -46,6 +47,7 @@ class FileTests(TestCase): self.assertEqual(obj1.normal.read(3), "con") self.assertEqual(obj1.normal.read(), "tent") self.assertEqual(list(obj1.normal.chunks(chunk_size=2)), ["co", "nt", "en", "t"]) + obj1.normal.close() # Save another file with the same name. obj2 = Storage() @@ -78,12 +80,14 @@ class FileTests(TestCase): obj3 = Storage.objects.create() self.assertEqual(obj3.default.name, "tests/default.txt") self.assertEqual(obj3.default.read(), "default content") + obj3.default.close() # But it shouldn't be deleted, even if there are no more objects using # it. obj3.delete() obj3 = Storage() self.assertEqual(obj3.default.read(), "default content") + obj3.default.close() # Verify the fix for #5655, making sure the directory is only # determined once. |
