/tests/modeltests/files/tests_25.py
https://code.google.com/p/mango-py/ · Python · 17 lines · 13 code · 4 blank · 0 comment · 1 complexity · 8175c33d72b7b7a9b99e50299772d12d MD5 · raw file
- from __future__ import with_statement
- import tempfile
- from django.core.files import File
- from django.utils.unittest import TestCase
- class FileObjTests(TestCase):
- def test_context_manager(self):
- orig_file = tempfile.TemporaryFile()
- base_file = File(orig_file)
- with base_file as f:
- self.assertIs(base_file, f)
- self.assertFalse(f.closed)
- self.assertTrue(f.closed)
- self.assertTrue(orig_file.closed)