def test_start_end(self): assert DOT(G(N('start', {N('end'): None}))).encode() == \ lstrip(''' | digraph { | start -> end | } ''')
def test_multilevel_suite(self): assert parse(''' | if q: | if q2: | first | second ''') == G( N('q', {N('q2', {N('first', {N('second'): None}): True}): True}))
def test_if_else(self): assert DOT(G(N('q', {N('y'): True, N('n'): False}))).encode() == \ lstrip(''' | digraph { | q -> y [label=True] | q -> n [label=False] | } ''')
def test_if_else(self): assert parse(''' | if q: | y | else: | n ''') == G(N('q', { N('y'): True, N('n'): False }))
def test_if_elif_elif_else(self): assert parse(''' | if q: | y | elif q2: | y2 | elif q3: | y3 | else: | n ''') == \ G(N('q', { N('y'): True, N('q2', { N('y2'): True, N('q3', { N('y3'): True, N('n'): False }): False }): False }))
def test_if_is(self): assert parse(''' | if s is o1: | y10 | y11 | elif s is o2: | y2 | elif s is o3: | y3 | else: | n ''') == \ G(N('s', { N('y10', {N('y11'): None}): 'o1', N('y2'): 'o2', N('y3'): 'o3', N('n'): False }))
def test__iter__(self, start_end): assert list(Graph(start_end)) == [N('start'), N('end')]
def test__setitem__(self, start_end): g = N('start') g[N('end')] = None assert list(g.children) == list(start_end.children)
def test__delitem__(self, start_end): del start_end[N('end')] assert not start_end.children
def test__getitem__(self, start_end): assert start_end[N('end')] == None
def test__iter__(self, start_end): assert tuple(iter(start_end)) == tuple({N('end'): None})
def test__lt__(self, start_end): assert start_end < N('z')
def test__eq__(self, start_end): assert start_end == N('start') assert start_end != N('end')
def test__eq__(self, start_end): assert Graph(start_end) == Graph(N('start', {N('end'): None})) assert Graph(start_end) != Graph(N('start')) assert Graph(start_end) != Graph( N('start', {N('end', {N('extra'): None}): None})) assert Graph(start_end) != Graph(N('start', {N('end'): True})) assert Graph(N('q', {N('y'): True, N('n'): False})) == \ Graph(N('q', {N('n'): False, N('y'): True}))
def start_end(): return 'start; end', G(N('start', {N('end'): None}))
def test_if(self): assert parse(''' | if q: | y ''') == G(N('q', {N('y'): True}))
def test_if_not(self): assert parse(''' | if not q: | y ''') == G(N('q', {N('y'): False}))
def test_multistatemnt_suite(self): assert parse(''' | if q: | first | second ''') == G(N('q', {N('first', {N('second'): None}): True}))
def start_end(): return N('start', {N('end'): None})
def test_children(self, start_end): assert start_end.children == {N('end'): None}