mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
f5f18a38ab
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14671 bcc190cf-cafb-0310-a4f2-bffc1f526a37
18 lines
467 B
Python
18 lines
467 B
Python
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)
|