Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import ast
import inspect
import executing
executing.TESTING = 1
from executing import Source
class Tester(object):
def get_node(self, typ):
frame = inspect.currentframe().f_back.f_back
Source.lazycache(frame)
node = Source.executing(frame).node
assert isinstance(node, typ), (node, typ)
return node
def check(self, node, value):
frame = inspect.currentframe().f_back.f_back
result = eval(
compile(ast.Expression(node), frame.f_code.co_filename, 'eval'),