test_lib_sequences.py 文件源码

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

项目:sidekick 作者: fabiommendes 项目源码 文件源码
def test_join(self):
        names = [(1, 'one'), (2, 'two'), (3, 'three')]
        fruit = [('apple', 1), ('orange', 1), ('banana', 2), ('coconut', 2)]

        def addpair(pair):
            return pair[0] + pair[1]

        result = set(starmap(add, join(first, names, second, fruit)))

        expected = {((1, 'one', 'apple', 1)), ((1, 'one', 'orange', 1)),
                    ((2, 'two', 'banana', 2)), ((2, 'two', 'coconut', 2))}

        assert result == expected

        result = set(starmap(add, join(first, names, second, fruit,
                                       left_default=no_default2,
                                       right_default=no_default2)))
        assert result == expected
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号