def test_string_reprs(self): for if_, exp_str, exp_repr in [ (IfBranch(), 'IF None', "IfBranch(type='IF', condition=None)"), (IfBranch(condition='$x > 1'), 'IF $x > 1', "IfBranch(type='IF', condition='$x > 1')"), (IfBranch(ELSE_IF, condition='$x > 2'), 'ELSE IF $x > 2', "IfBranch(type='ELSE IF', condition='$x > 2')"), (IfBranch(ELSE), 'ELSE', "IfBranch(type='ELSE', condition=None)"), (IfBranch(condition=u'$x == "\xe4iti"'), u'IF $x == "\xe4iti"', u"IfBranch(type='IF', condition=%r)" % u'$x == "\xe4iti"'), ]: assert_equal(str(if_), exp_str) assert_equal(repr(if_), 'robot.model.' + exp_repr)
def test_branch_id_without_parent(self): assert_equal(IfBranch().id, 'k1')
def test_type_with_nested_if(self): branch = IfBranch() branch.body.create_if() assert_equal(branch.body[0].body.create_branch().type, IF) assert_equal(branch.body[0].body.create_branch(ELSE_IF).type, ELSE_IF) assert_equal(branch.body[0].body.create_branch(ELSE).type, ELSE)
def test_type(self): assert_equal(IfBranch().type, IF) assert_equal(IfBranch(type=ELSE).type, ELSE) assert_equal(IfBranch(type=ELSE_IF).type, ELSE_IF)