PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms 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 | 1 complexity | 8175c33d72b7b7a9b99e50299772d12d MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from __future__ import with_statement
  2. import tempfile
  3. from django.core.files import File
  4. from django.utils.unittest import TestCase
  5. class FileObjTests(TestCase):
  6. def test_context_manager(self):
  7. orig_file = tempfile.TemporaryFile()
  8. base_file = File(orig_file)
  9. with base_file as f:
  10. self.assertIs(base_file, f)
  11. self.assertFalse(f.closed)
  12. self.assertTrue(f.closed)
  13. self.assertTrue(orig_file.closed)