def test_test_neg5(): try: with open('./tests/_correction/test_neg5') as f: content = f.readlines() except: print('Error opening file for reading') raise parser = ESParser(content) tree = NPITree(parser.structured_rules, parser.facts, parser.queries) assert tree.resolve_query("A") is False
def test_mix2(): try: with open('./tests/_examples/good_files/mix2.txt') as f: content = f.readlines() except: print('Error opening file for reading') raise parser = ESParser(content) tree = NPITree(parser.structured_rules, parser.facts, parser.queries) assert tree.resolve_query("C") is True
def test_multiple_initial_facts5(): try: with open('./tests/_examples/good_files/multiple_initial_facts5.txt' ) as f: content = f.readlines() except: print('Error opening file for reading') raise parser = ESParser(content) tree = NPITree(parser.structured_rules, parser.facts, parser.queries) assert tree.resolve_query("E") is False assert tree.resolve_query("F") is False
def test_good_files(input, expected): with open("./tests/_examples/good_files/" + input) as f: file_lines = f.readlines(1000) parser = ESParser(file_lines) tree = NPITree(parser.structured_rules, parser.facts, parser.queries) i = 0 for query in parser.queries: if expected[i] == "ERROR": try: tree.resolve_query(query) except: pass continue assert False else: assert tree.resolve_query(query) == expected[i] i += 1