test_storage_fs.py 文件源码

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

项目:aioworkers 作者: aioworkers 项目源码 文件源码
def test_key(loop):
    with tempfile.TemporaryDirectory() as d:
        config = MergeDict(
            name='',
            path=d,
            executor=None,
        )
        context = Context({}, loop=loop)
        storage = FileSystemStorage(config, context=context, loop=loop)
        await storage.init()

        assert str(storage.raw_key(('1', '3', ('4',)))).endswith('1/3/4')
        assert str(storage.raw_key((PurePath('1'), '3', ('4',)))).endswith('1/3/4')

        with pytest.raises(TypeError):
            storage.raw_key(1)

        with pytest.raises(ValueError):
            storage.raw_key('../..')

        with pytest.raises(ValueError):
            storage.raw_key('/abs/path')

        with pytest.raises(ValueError):
            storage.raw_key(PurePath('/abs/path'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号