コード例 #1
0
ファイル: test_io.py プロジェクト: drastorguev/pythondojo
def test_IOStream_init():
    """IOStream initializes from a file-like object missing attributes. """
    # Cause a failure from getattr and dir(). (Issue #6386)
    class BadStringIO(stdlib_io.StringIO):
        def __dir__(self):
            attrs = super(BadStringIO, self).__dir__()
            attrs.append('name')
            return attrs

    iostream = IOStream(BadStringIO())
    iostream.write(u'hi, bad iostream\n')
    assert not hasattr(iostream, 'name')
コード例 #2
0
def test_IOStream_init():
    """IOStream initializes from a file-like object missing attributes. """
    # Cause a failure from getattr and dir(). (Issue #6386)
    class BadStringIO(StringIO):
        def __dir__(self):
            attrs = super(StringIO, self).__dir__()
            attrs.append('name')
            return attrs

    iostream = IOStream(BadStringIO())
    iostream.write('hi, bad iostream\n')
    assert not hasattr(iostream, 'name')
コード例 #3
0
ファイル: test_io.py プロジェクト: terrdavis/ipython
    def test_IOStream_init(self):
        """IOStream initializes from a file-like object missing attributes. """

        # Cause a failure from getattr and dir(). (Issue #6386)
        class BadStringIO(StringIO):
            def __dir__(self):
                attrs = super().__dir__()
                attrs.append("name")
                return attrs

        with self.assertWarns(DeprecationWarning):
            iostream = IOStream(BadStringIO())
            iostream.write("hi, bad iostream\n")

        assert not hasattr(iostream, "name")
        iostream.close()