def test_string_reprs(self): for try_, exp_str, exp_repr in [ (TryBranch(), 'TRY', "TryBranch(type='TRY')"), (TryBranch(EXCEPT), 'EXCEPT', "TryBranch(type='EXCEPT', patterns=(), variable=None)"), (TryBranch(EXCEPT, ('Message',)), 'EXCEPT Message', "TryBranch(type='EXCEPT', patterns=('Message',), variable=None)"), (TryBranch(EXCEPT, ('M', 'S', 'G', 'S')), 'EXCEPT M S G S', "TryBranch(type='EXCEPT', patterns=('M', 'S', 'G', 'S'), variable=None)"), (TryBranch(EXCEPT, (), '${x}'), 'EXCEPT AS ${x}', "TryBranch(type='EXCEPT', patterns=(), variable='${x}')"), (TryBranch(EXCEPT, ('Message',), '${x}'), 'EXCEPT Message AS ${x}', "TryBranch(type='EXCEPT', patterns=('Message',), variable='${x}')"), (TryBranch(ELSE), 'ELSE', "TryBranch(type='ELSE')"), (TryBranch(FINALLY), 'FINALLY', "TryBranch(type='FINALLY')"), ]: assert_equal(str(try_), exp_str) assert_equal(repr(try_), 'robot.model.' + exp_repr)
def test_type_with_nested_Try(self): branch = TryBranch() branch.body.create_try() assert_equal(branch.body[0].body.create_branch().type, TRY) assert_equal(branch.body[0].body.create_branch(type=EXCEPT).type, EXCEPT) assert_equal(branch.body[0].body.create_branch(type=ELSE).type, ELSE) assert_equal(branch.body[0].body.create_branch(type=FINALLY).type, FINALLY)
def test_type(self): assert_equal(TryBranch().type, TRY) assert_equal(TryBranch(type=EXCEPT).type, EXCEPT) assert_equal(TryBranch(type=ELSE).type, ELSE) assert_equal(TryBranch(type=FINALLY).type, FINALLY)
def test_branch_id_without_parent(self): assert_equal(TryBranch().id, 'k1')