MCPcopy Create free account
hub / github.com/ipython/ipython / test_IOStream_init

Method test_IOStream_init

IPython/utils/tests/test_io.py:66–79  ·  view source on GitHub ↗

IOStream initializes from a file-like object missing attributes.

(self)

Source from the content-addressed store, hash-verified

64class TestIOStream(unittest.TestCase):
65
66 def test_IOStream_init(self):
67 """IOStream initializes from a file-like object missing attributes. """
68 # Cause a failure from getattr and dir(). (Issue #6386)
69 class BadStringIO(StringIO):
70 def __dir__(self):
71 attrs = super().__dir__()
72 attrs.append('name')
73 return attrs
74 with self.assertWarns(DeprecationWarning):
75 iostream = IOStream(BadStringIO())
76 iostream.write('hi, bad iostream\n')
77
78 assert not hasattr(iostream, 'name')
79 iostream.close()
80
81 def test_capture_output(self):
82 """capture_output() context works"""

Callers

nothing calls this directly

Calls 4

writeMethod · 0.95
closeMethod · 0.95
IOStreamClass · 0.90
BadStringIOClass · 0.85

Tested by

no test coverage detected