Back to index

python3.2  3.2.2
Public Member Functions
test.test_contextlib.FileContextTestCase Class Reference

List of all members.

Public Member Functions

def testWithOpen

Detailed Description

Definition at line 137 of file test_contextlib.py.


Member Function Documentation

Definition at line 139 of file test_contextlib.py.

00139 
00140     def testWithOpen(self):
00141         tfn = tempfile.mktemp()
00142         try:
00143             f = None
00144             with open(tfn, "w") as f:
00145                 self.assertFalse(f.closed)
00146                 f.write("Booh\n")
00147             self.assertTrue(f.closed)
00148             f = None
00149             with self.assertRaises(ZeroDivisionError):
00150                 with open(tfn, "r") as f:
00151                     self.assertFalse(f.closed)
00152                     self.assertEqual(f.read(), "Booh\n")
00153                     1 / 0
00154             self.assertTrue(f.closed)
00155         finally:
00156             support.unlink(tfn)
00157 
@unittest.skipUnless(threading, 'Threading required for this test.')

Here is the call graph for this function:


The documentation for this class was generated from the following file: