def show_expr(self): ''' Convenient for debugging when %check_expr fails. ''' _, hash_id = os.path.split(os.path.abspath('.')) context = Context() stored_expr = context.getStoredExpr(hash_id) return stored_expr
def check_expr(self, expr_name, expr): _, hash_id = os.path.split(os.path.abspath('.')) context = Context() stored_expr = context.getStoredExpr(hash_id) if expr != stored_expr: raise ProveItMagicFailure("The built '%s' does not match the stored Expression"%expr_name) if expr._style_id != stored_expr._style_id: raise ProveItMagicFailure("The built '%s' style does not match that of the stored Expression"%expr_name) print("Passed sanity check: built '%s' is the same as the stored Expression."%expr_name)
def check_expr(self, line): _, hash_id = os.path.split(os.path.abspath('.')) context = Context() expr_name = line.strip() if expr_name == '': expr_name = 'expr' expr = self.shell.user_ns[expr_name] else: expr = self.shell.user_ns[expr_name] if isinstance(expr, KnownTruth): # actually a KnownTruth; convert to an Expression expr = expr.expr stored_expr = context.getStoredExpr(hash_id) if expr != stored_expr: raise ProveItMagicFailure("The built '%s' does not match the stored Expression"%expr_name) if expr._style_id != stored_expr._style_id: raise ProveItMagicFailure("The built '%s' style does not match that of the stored Expression"%expr_name) print "Passed sanity check: built '%s' is the same as the stored Expression."%expr_name