diff --git a/django/core/files/base.py b/django/core/files/base.py
index 9030ed9..74a1e41 100644
a
|
b
|
class File(FileProxyMixin):
|
114 | 114 | yield buffer_ |
115 | 115 | |
116 | 116 | def __enter__(self): |
| 117 | self.open() |
117 | 118 | return self |
118 | 119 | |
119 | 120 | def __exit__(self, exc_type, exc_value, tb): |
diff --git a/tests/files/tests.py b/tests/files/tests.py
index 4036fc5..ced9a77 100644
a
|
b
|
class FileTests(unittest.TestCase):
|
38 | 38 | self.assertTrue(f.closed) |
39 | 39 | self.assertTrue(orig_file.closed) |
40 | 40 | |
| 41 | def test_context_manager_open(self): |
| 42 | my_file = ContentFile('test') |
| 43 | with my_file as f: |
| 44 | self.assertEqual(f.read(), 'test') |
| 45 | |
| 46 | with my_file as f: |
| 47 | self.assertEqual(f.read(), 'test') |
| 48 | |
41 | 49 | def test_namedtemporaryfile_closes(self): |
42 | 50 | """ |
43 | 51 | The symbol django.core.files.NamedTemporaryFile is assigned as |