def test_oplist_creation(): l = oplist(range(10)) assert len(l) == 10 l = oplist([1, 2]) assert len(l) == 2 l = oplist((1, 2)) assert len(l) == 2 assert l[0] == 1 assert l[1] == 2
def test_oplist_imath(op, key): d = { 1: oplist([ar.aranged(1, 10), ar.aranged(1, 10)]), 2: 2, } l2 = d[key] try: l1 = oplist([data * 2 for data in l2]) except: l1 = oplist([ar.aranged(1, 10), ar.aranged(2, 3)]) op(l1, l2)
def test_oplist_math(op, key1, key2): d = { 1: oplist([ar.aranged(1, 10), ar.aranged(1, 10)]), 2: 2, } l1 = d[key1] l2 = d[key2] op(l1, l2)
def my_func(): return oplist([1, 2])
def test_oplist_fail_imath(op): l1 = oplist([1, 2]) l2 = [1, 2, 3] op(l1, l2)
def test_oplist_fail_rmath(op): l1 = oplist([1, 2]) l2 = [1, 2, 3] op(l2, l1)
def test_oplist_fail_imath(op): l1 = oplist([1, 2]) l2 = [1, 2, 3] with pytest.raises(ValueError): op(l1, l2)
def test_oplist_single(op): d = oplist([ar.aranged(1, 10), ar.aranged(1, 10)]) op(d)
def _asoplist(arg): if isinstance(arg, tuple): return oplist(arg) elif isinstance(arg, list) and not isinstance(arg, oplist): return oplist(arg) return arg
def func(*args, **kwargs): return oplist(v for v in iter_func(*args, **kwargs))
def _asoplist(arg): if isinstance(arg, (tuple, list)) and not isinstance(arg, oplist): return oplist(arg) return arg