Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init():
l = DogmaticList()
assert l == []
l2 = DogmaticList([2, 3, 1])
assert l2 == [2, 3, 1]
def is_dogmatic(a):
if isinstance(a, (DogmaticDict, DogmaticList)):
return True
elif isinstance(a, dict):
return any(is_dogmatic(v) for v in a.values())
elif isinstance(a, (list, tuple)):
return any(is_dogmatic(v) for v in a)
def test_setslice():
l = DogmaticList([1, 2, 3])
l[1:3] = [4, 5]
assert l == [1, 2, 3]
def test_sort():
l = DogmaticList([3, 1, 2])
l.sort()
assert l == [3, 1, 2]
def test_delslice():
l = DogmaticList([1, 2, 3])
del l[1:]
assert l == [1, 2, 3]
def test_list_interface_count():
l = DogmaticList([1, 2, 4, 4, 5])
assert l.count(1) == 1
assert l.count(3) == 0
assert l.count(4) == 2
def test_list_interface_getitem():
l = DogmaticList([0, 1, 2])
assert l[0] == 0
assert l[1] == 1
assert l[2] == 2
assert l[-1] == 2
assert l[-2] == 1
assert l[-3] == 0
def test_extend():
l = DogmaticList([1, 2])
l.extend([3, 4])
assert l == [1, 2]
def test_empty_revelation():
l = DogmaticList([1, 2, 3])
assert l.revelation() == set()
def test_imul():
l = DogmaticList([1, 2])
l *= 4
assert l == [1, 2]