def test_dependencies(): # we need a real libido_parser for that from libido_parser import libido_parser, symbol lp = libido_parser(config={}, parser_factory=None) p = _create_parser(lp) p.parse('input.bash') expect = {'one': symbol(tsym='chunk', deps=[]), 'three': symbol(tsym='chunk', deps=['two']), 'two': symbol(tsym='chunk', deps=['one'])} assert p.libido_parser.token_map == expect
def test_get_dep(): p = _create_parser() p.token_map = { "code": symbol(tsym="var", deps=["three"]), "die": symbol(tsym="chunk", deps=[]), "one": symbol(tsym="chunk", deps=[]), "test_tool": symbol(tsym="chunk", deps=["die"]), "three": symbol(tsym="chunk", deps=["two"]), "two": symbol(tsym="chunk", deps=["one"]), } d = p.get_dep("three") assert sorted(d) == sorted(["one", "two", "three"]) d = p.get_dep("three", not_me=True) assert sorted(d) == sorted(["one", "two"]) d = p.get_dep("code", not_me=True) assert sorted(d) == sorted(["one", "two", "three"]) d = p.get_dep("die") assert d == ["die"]