Back to index

python3.2  3.2.2
Public Member Functions
test.test_io.CommonBufferedTests Class Reference
Inheritance diagram for test.test_io.CommonBufferedTests:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def test_detach
def test_fileno
def test_no_fileno
def test_invalid_args
def test_override_destructor
def test_context_manager
def test_error_through_destructor
def test_repr
def test_flush_error_on_close
def test_multi_close
def test_unseekable
def test_readonly_attributes

Detailed Description

Definition at line 637 of file test_io.py.


Member Function Documentation

Definition at line 692 of file test_io.py.

00692 
00693     def test_context_manager(self):
00694         # Test usability as a context manager
00695         rawio = self.MockRawIO()
00696         bufio = self.tp(rawio)
00697         def _with():
00698             with bufio:
00699                 pass
00700         _with()
00701         # bufio should now be closed, and using it a second time should raise
00702         # a ValueError.
00703         self.assertRaises(ValueError, _with)

Here is the call graph for this function:

Definition at line 640 of file test_io.py.

00640 
00641     def test_detach(self):
00642         raw = self.MockRawIO()
00643         buf = self.tp(raw)
00644         self.assertIs(buf.detach(), raw)
00645         self.assertRaises(ValueError, buf.detach)

Here is the call graph for this function:

Definition at line 704 of file test_io.py.

00704 
00705     def test_error_through_destructor(self):
00706         # Test that the exception state is not modified by a destructor,
00707         # even if close() fails.
00708         rawio = self.CloseFailureIO()
00709         def f():
00710             self.tp(rawio).xyzzy
00711         with support.captured_output("stderr") as s:
00712             self.assertRaises(AttributeError, f)
00713         s = s.getvalue().strip()
00714         if s:
00715             # The destructor *may* have printed an unraisable error, check it
00716             self.assertEqual(len(s.splitlines()), 1)
00717             self.assertTrue(s.startswith("Exception IOError: "), s)
00718             self.assertTrue(s.endswith(" ignored"), s)

Here is the call graph for this function:

Definition at line 646 of file test_io.py.

00646 
00647     def test_fileno(self):
00648         rawio = self.MockRawIO()
00649         bufio = self.tp(rawio)
00650 
00651         self.assertEqual(42, bufio.fileno())

Here is the call graph for this function:

Definition at line 729 of file test_io.py.

00729 
00730     def test_flush_error_on_close(self):
00731         raw = self.MockRawIO()
00732         def bad_flush():
00733             raise IOError()
00734         raw.flush = bad_flush
00735         b = self.tp(raw)
00736         self.assertRaises(IOError, b.close) # exception not swallowed

Here is the call graph for this function:

Definition at line 657 of file test_io.py.

00657 
00658     def test_invalid_args(self):
00659         rawio = self.MockRawIO()
00660         bufio = self.tp(rawio)
00661         # Invalid whence
00662         self.assertRaises(ValueError, bufio.seek, 0, -1)
00663         self.assertRaises(ValueError, bufio.seek, 0, 3)

Here is the call graph for this function:

Definition at line 737 of file test_io.py.

00737 
00738     def test_multi_close(self):
00739         raw = self.MockRawIO()
00740         b = self.tp(raw)
00741         b.close()
00742         b.close()
00743         b.close()
00744         self.assertRaises(ValueError, b.flush)

Here is the call graph for this function:

Definition at line 652 of file test_io.py.

00652 
00653     def test_no_fileno(self):
00654         # XXX will we always have fileno() function? If so, kill
00655         # this test. Else, write it.
00656         pass

Definition at line 664 of file test_io.py.

00664 
00665     def test_override_destructor(self):
00666         tp = self.tp
00667         record = []
00668         class MyBufferedIO(tp):
00669             def __del__(self):
00670                 record.append(1)
00671                 try:
00672                     f = super().__del__
00673                 except AttributeError:
00674                     pass
00675                 else:
00676                     f()
00677             def close(self):
00678                 record.append(2)
00679                 super().close()
00680             def flush(self):
00681                 record.append(3)
00682                 super().flush()
00683         rawio = self.MockRawIO()
00684         bufio = MyBufferedIO(rawio)
00685         writable = bufio.writable()
00686         del bufio
00687         support.gc_collect()
00688         if writable:
00689             self.assertEqual(record, [1, 2, 3])
00690         else:
00691             self.assertEqual(record, [1, 2])

Here is the call graph for this function:

Definition at line 750 of file test_io.py.

00750 
00751     def test_readonly_attributes(self):
00752         raw = self.MockRawIO()
00753         buf = self.tp(raw)
00754         x = self.MockRawIO()
00755         with self.assertRaises(AttributeError):
00756             buf.raw = x
00757 

Here is the call graph for this function:

Definition at line 719 of file test_io.py.

00719 
00720     def test_repr(self):
00721         raw = self.MockRawIO()
00722         b = self.tp(raw)
00723         clsname = "%s.%s" % (self.tp.__module__, self.tp.__name__)
00724         self.assertEqual(repr(b), "<%s>" % clsname)
00725         raw.name = "dummy"
00726         self.assertEqual(repr(b), "<%s name='dummy'>" % clsname)
00727         raw.name = b"dummy"
00728         self.assertEqual(repr(b), "<%s name=b'dummy'>" % clsname)

Here is the call graph for this function:

Definition at line 745 of file test_io.py.

00745 
00746     def test_unseekable(self):
00747         bufio = self.tp(self.MockUnseekableIO(b"A" * 10))
00748         self.assertRaises(self.UnsupportedOperation, bufio.tell)
00749         self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)

Here is the call graph for this function:


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