PageRenderTime 39ms CodeModel.GetById 36ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/modeltests/files/tests_25.py

https://code.google.com/p/mango-py/
Python | 17 lines | 13 code | 4 blank | 0 comment | 0 complexity | 8175c33d72b7b7a9b99e50299772d12d MD5 | raw file
 1from __future__ import with_statement
 2
 3import tempfile
 4
 5from django.core.files import File
 6from django.utils.unittest import TestCase
 7
 8
 9class FileObjTests(TestCase):
10    def test_context_manager(self):
11        orig_file = tempfile.TemporaryFile()
12        base_file = File(orig_file)
13        with base_file as f:
14            self.assertIs(base_file, f)
15            self.assertFalse(f.closed)
16        self.assertTrue(f.closed)
17        self.assertTrue(orig_file.closed)