1 *** Settings ***
2 Library Collections
3 *** Test Cases ***
4 list
5 ${list1} create list a b c
6 ${list2} create list 1 2 3
7 append to list ${list1} d
8 log to console ${list1} # ['a', 'b', 'c', 'd']
9 ${list3} combine lists ${list1} ${list2}
10 log to console ${list3} #['a', 'b', 'c', 'd', '1', '2', '3']
11 ${list6} evaluate [1,2,3,3,5,2,1,6,3]
12 ${list4} convert to list ${list6}
13 log to console ${list4} #[1, 2, 3]
14 ${list7} evaluate [1,[3,4],6,7]
15 ${list8} copy list ${list7} deepcopy=True
16 log to console ${list8}
17 ${count} count values in list ${list6} ${3} start=0
18 log to console ${count} # 3
19 ${list9} create list a b c d
20 lists should be equal ${list1} ${list9}
21 ${var} get from list ${list1} 1
22 log to console ${var} # 返回下标为1的元素 b
23 ${list11} create list a b c d a a1a
24 ${index} get index from list ${list11} a start=1 end=None
25 log to console ${index} # 返回元素下标(找到即返回),可以指定寻找范围
26 ${var1} get match count ${list11} a*
27 log to console ${var1} #匹配列表中出现a的次数
28 insert into list ${list11} 1 ff
29 log to console ${list11} # 指定index插入值到列表中['a', 'ff', 'b', 'c', 'd', 'a', 'a1a']
30 remove values from list ${list11} ff a1a
31 log to console ${list11} # 从列表中移除元素 ['a', 'b', 'c', 'd', 'a']
32 remove from list ${list11} 0
33 log to console ${list11} # 根据index从列表中移除元素['b', 'c', 'd', 'a']
34 set list value ${list11} 0 gg
35 log to console ${list11} # 根据index 修改元素['gg', 'c', 'd', 'a']
36 sort list ${list11}
37 log to console ${list11} # ['a', 'c', 'd', 'gg']
38
39 dictionary
40 ${dict1} create dictionary a=1 b=2 c=3
41 ${dict2} convert to dictionary ${dict1}
42 log to console ${dict1}
43 ${dict3} evaluate {'a':[1,2,3],'b':{'x':1,'y':2}}
44 dictionaries should be equal ${dict1} ${dict2}
45 dictionary should contain item ${dict1} a 1
46 dictionary should contain key ${dict1} a
47 dictionary should contain value ${dict1} 1
48 ${dict4} evaluate {'b':{'x':1,'y':2}}
49 dictionary should contain sub dictionary ${dict3} ${dict4} # 第一个参数包含第二个参数
50 ${items} get dictionary items ${dict1} sort_keys=False
51 log to console ${items} #['a', '1', 'b', '2', 'c', '3']
52 ${keys} get dictionary keys ${dict1} sort_keys=False
53 log to console ${keys} #['a', 'b', 'c']
54 ${values} get dictionary values ${dict1}
55 log to console ${values} #['1', '2', '3']
56 ${value} get from dictionary ${dict1} a
57 log to console ${value} # 返回key为a的value 1