本文整理汇总了Python中robot.model.itemlist.ItemList类的典型用法代码示例。如果您正苦于以下问题:Python ItemList类的具体用法?Python ItemList怎么用?Python ItemList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemList类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_insert
def test_insert(self):
items = ItemList(str)
items.insert(0, 'a')
items.insert(0, 'b')
items.insert(3, 'c')
items.insert(1, 'd')
assert_equal(list(items), ['b', 'd', 'a', 'c'])
开发者ID:BanerjeeSandipan,项目名称:robotframework,代码行数:7,代码来源:test_itemlist.py
示例2: test_pop
def test_pop(self):
items = ItemList(str, items='abcde')
assert_equal(items.pop(), 'e')
assert_equal(items.pop(0), 'a')
assert_equal(items.pop(-2), 'c')
assert_equal(list(items), ['b', 'd'])
assert_raises(IndexError, items.pop, 7)
assert_equal(list(items), ['b', 'd'])
assert_raises(IndexError, ItemList(int).pop)
开发者ID:MarynaQA,项目名称:robotframework,代码行数:9,代码来源:test_itemlist.py
示例3: test_create_with_args_and_kwargs
def test_create_with_args_and_kwargs(self):
class Item(object):
def __init__(self, arg1, arg2):
self.arg1 = arg1
self.arg2 = arg2
items = ItemList(Item)
item = items.create('value 1', arg2='value 2')
assert_equal(item.arg1, 'value 1')
assert_equal(item.arg2, 'value 2')
assert_equal(list(items), [item])
开发者ID:strimber,项目名称:robotframework,代码行数:10,代码来源:test_itemlist.py
示例4: test_common_attrs
def test_common_attrs(self):
item1 = Object()
item2 = Object()
parent = object()
items = ItemList(Object, {'attr': 2, 'parent': parent}, [item1])
items.append(item2)
assert_true(item1.parent is parent)
assert_equal(item1.attr, 2)
assert_true(item2.parent is parent)
assert_equal(item2.attr, 2)
assert_equal(list(items), [item1, item2])
开发者ID:strimber,项目名称:robotframework,代码行数:11,代码来源:test_itemlist.py
示例5: test_index_with_start_and_stop
def test_index_with_start_and_stop(self):
numbers = [0, 1, 2, 3, 2, 1, 0]
items = ItemList(int, items=numbers)
for num in sorted(set(numbers)):
for start in range(len(numbers)):
if num in numbers[start:]:
assert_equal(items.index(num, start),
numbers.index(num, start))
for end in range(start, len(numbers)):
if num in numbers[start:end]:
assert_equal(items.index(num, start, end),
numbers.index(num, start, end))
开发者ID:strimber,项目名称:robotframework,代码行数:12,代码来源:test_itemlist.py
示例6: test_extend_with_generator
def test_extend_with_generator(self):
items = ItemList(str)
items.extend((c for c in 'Hello, world!'))
assert_equal(list(items), list('Hello, world!'))
开发者ID:strimber,项目名称:robotframework,代码行数:4,代码来源:test_itemlist.py
示例7: test_append_and_extend
def test_append_and_extend(self):
items = ItemList(int)
items.append(1)
items.append(2)
items.extend((3, 4))
assert_equal(list(items), [1, 2, 3, 4])
开发者ID:strimber,项目名称:robotframework,代码行数:6,代码来源:test_itemlist.py
示例8: test_create_items
def test_create_items(self):
items = ItemList(str)
item = items.create(object=1)
assert_true(isinstance(item, str))
assert_equal(item, '1')
assert_equal(list(items), [item])
开发者ID:strimber,项目名称:robotframework,代码行数:6,代码来源:test_itemlist.py
示例9: test_clear
def test_clear(self):
items = ItemList(int, range(10))
items.clear()
assert_equal(len(items), 0)
开发者ID:strimber,项目名称:robotframework,代码行数:4,代码来源:test_itemlist.py
示例10: test_len
def test_len(self):
items = ItemList(object)
assert_equal(len(items), 0)
items.create()
assert_equal(len(items), 1)
开发者ID:strimber,项目名称:robotframework,代码行数:5,代码来源:test_itemlist.py
示例11: test_index
def test_index(self):
items = ItemList(str, items=('first', 'second'))
assert_equal(items.index('first'), 0)
assert_equal(items.index('second'), 1)
assert_raises(ValueError, items.index, 'nonex')
开发者ID:strimber,项目名称:robotframework,代码行数:5,代码来源:test_itemlist.py
示例12: test_index
def test_index(self):
items = ItemList(str, items=("first", "second"))
assert_equal(items.index("first"), 0)
assert_equal(items.index("second"), 1)
开发者ID:justinmellinger,项目名称:robotframework,代码行数:4,代码来源:test_itemlist.py
注:本文中的robot.model.itemlist.ItemList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论