test_integration.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:stor 作者: counsyl 项目源码 文件源码
def test_custom_encoding_text(self):
            test_file = self.test_dir / 'test_file.txt'
            with stor.open(test_file, mode='w', encoding='utf-16') as fp:
                fp.write(STRING_STRING)

            with stor.open(test_file, mode='r', encoding='utf-16') as fp:
                result = fp.read()
            assert result == STRING_STRING

            with pytest.raises(UnicodeDecodeError):
                with stor.open(test_file, mode='r', encoding='utf-8') as fp:
                    result = fp.read()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号