5 Unit tests for the mavexpression library 8 from __future__
import print_function
12 from pymavlink
import mavexpression
17 Class to test evaluate_expression 21 """Constructor, set up some data that is reused in many tests""" 25 super(ExpressionTest, self).
__init__(*args, **kwargs)
29 """Test the evaluate_expression functionality""" 30 assert mavexpression.evaluate_expression(
'1+2', {}) == 3
31 assert mavexpression.evaluate_expression(
'4/0', {})
is None 32 assert mavexpression.evaluate_expression(
'A+4', {})
is None 35 """Test the evaluate_expression functionality with local vars""" 36 assert mavexpression.evaluate_expression(
'lat+10', self.
varsDict) == 15.67
37 assert mavexpression.evaluate_expression(
'4.0/speed', self.
varsDict) == 0.5
38 assert mavexpression.evaluate_expression(
'speed+lat+wrong', self.
varsDict)
is None 41 """Test evaluate_expression using the functions in mavextra.py""" 42 assert mavexpression.evaluate_expression(
'kmh(10)', {}) == 36
43 assert mavexpression.evaluate_expression(
'angle_diff(170, -90)', {}) == -100
45 if __name__ ==
'__main__':
def __init__(self, args, kwargs)