summaryrefslogtreecommitdiff
path: root/tests/modeltests/files/tests_25.py
blob: 48eb6e26f7bd9b071f1791d9df26916504838040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)