def test_litset_eval(self): s = ast.LiteralSet([ast.Constant(True), ast.Literal('a'), ast.Literal('b')]) ctx = ast.EvalContext(MockPred(), {'a': 2, 'b': False}) res = s.eval(ctx) assert isinstance(res, frozenset) assert True in res assert False in res assert 2 in res
def test_cached_node_sets_cache(self): c = ast.Constant(False) n = ast.CachedNode(c, 0) ctx = ast.EvalContext(MockPred(), {}) assert not n.eval(ctx) assert not ctx.cached_res[0]
def test_litset_static(self): s = ast.LiteralSet([ast.Constant(True), ast.Literal('\"a\"')]) pred = MockPred() s.static_resolve(pred) ctx = ast.EvalContext(pred, {'a': 2, 'b': False}) res = s.eval(ctx) assert s.static assert isinstance(res, set) assert True in res assert "a" in res