当前位置: 首页>>代码示例>>Python>>正文


Python inference.is_file_like方法代码示例

本文整理汇总了Python中pandas.core.dtypes.inference.is_file_like方法的典型用法代码示例。如果您正苦于以下问题:Python inference.is_file_like方法的具体用法?Python inference.is_file_like怎么用?Python inference.is_file_like使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.core.dtypes.inference的用法示例。


在下文中一共展示了inference.is_file_like方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_is_file_like

# 需要导入模块: from pandas.core.dtypes import inference [as 别名]
# 或者: from pandas.core.dtypes.inference import is_file_like [as 别名]
def test_is_file_like():
    class MockFile(object):
        pass

    is_file = inference.is_file_like

    data = StringIO("data")
    assert is_file(data)

    # No read / write attributes
    # No iterator attributes
    m = MockFile()
    assert not is_file(m)

    MockFile.write = lambda self: 0

    # Write attribute but not an iterator
    m = MockFile()
    assert not is_file(m)

    # gh-16530: Valid iterator just means we have the
    # __iter__ attribute for our purposes.
    MockFile.__iter__ = lambda self: self

    # Valid write-only file
    m = MockFile()
    assert is_file(m)

    del MockFile.write
    MockFile.read = lambda self: 0

    # Valid read-only file
    m = MockFile()
    assert is_file(m)

    # Iterator but no read / write attributes
    data = [1, 2, 3]
    assert not is_file(data) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:40,代码来源:test_inference.py

示例2: test_is_file_like

# 需要导入模块: from pandas.core.dtypes import inference [as 别名]
# 或者: from pandas.core.dtypes.inference import is_file_like [as 别名]
def test_is_file_like():
    class MockFile(object):
        pass

    is_file = inference.is_file_like

    data = StringIO("data")
    assert is_file(data)

    # No read / write attributes
    # No iterator attributes
    m = MockFile()
    assert not is_file(m)

    MockFile.write = lambda self: 0

    # Write attribute but not an iterator
    m = MockFile()
    assert not is_file(m)

    # gh-16530: Valid iterator just means we have the
    # __iter__ attribute for our purposes.
    MockFile.__iter__ = lambda self: self

    # Valid write-only file
    m = MockFile()
    assert is_file(m)

    del MockFile.write
    MockFile.read = lambda self: 0

    # Valid read-only file
    m = MockFile()
    assert is_file(m)

    # Iterator but no read / write attributes
    data = [1, 2, 3]
    assert not is_file(data)

    if PY3:
        from unittest import mock
        assert not is_file(mock.Mock()) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:44,代码来源:test_inference.py


注:本文中的pandas.core.dtypes.inference.is_file_like方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。