本文整理汇总了Python中pyrsistent.b函数的典型用法代码示例。如果您正苦于以下问题:Python b函数的具体用法?Python b怎么用?Python b使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了b函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_empty_bag
def test_empty_bag():
"""
creating an empty pbag returns a singleton.
Note that this should NOT be relied upon in application code.
"""
assert b() is b()
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:7,代码来源:bag_test.py
示例2: assert_converge_clb_steps
def assert_converge_clb_steps(self, clb_descs, clb_nodes, clb_steps,
draining_timeout, now):
"""
Run the converge function on the given a server with the given
:class:`CLBDescription`s and :class:`CLBNode`s, the given
draining timeout, and the given time.
Assert that the LB steps produced are equivalent to the given
CLB steps.
Run the converge function again, this time with a default
:class:`RCv3Description` and a default :class:`RCv3Node` added, and
assert that the LB steps produced are equivalent to the given
CLB steps plus a RCv3 node removal, because RCv3 nodes are not
drainable and are hence unaffected by timeouts.
"""
without_rcv3_steps = converge(
DesiredGroupState(server_config={}, capacity=0,
draining_timeout=draining_timeout),
s(server('abc',
ServerState.ACTIVE,
servicenet_address=self.address,
desired_lbs=s(*clb_descs))),
s(*clb_nodes),
now=now)
self.assertEqual(self._filter_only_lb_steps(without_rcv3_steps),
b(*clb_steps))
rcv3_desc = RCv3Description(
lb_id='e762e42a-8a4e-4ffb-be17-f9dc672729b2')
rcv3_step = BulkRemoveFromRCv3(
lb_node_pairs=s(('e762e42a-8a4e-4ffb-be17-f9dc672729b2', 'abc')))
with_rcv3_steps = converge(
DesiredGroupState(server_config={}, capacity=0,
draining_timeout=draining_timeout),
s(server('abc',
ServerState.ACTIVE,
servicenet_address=self.address,
desired_lbs=s(rcv3_desc, *clb_descs))),
s(RCv3Node(node_id='43a39c18-8cad-4bb1-808e-450d950be289',
cloud_server_id='abc', description=rcv3_desc),
*clb_nodes),
now=now)
self.assertEqual(self._filter_only_lb_steps(with_rcv3_steps),
b(rcv3_step, *clb_steps))
开发者ID:pratikmallya,项目名称:otter,代码行数:48,代码来源:test_planning.py
示例3: test_pbag_is_unorderable
def test_pbag_is_unorderable():
with pytest.raises(TypeError):
_ = b(1) < b(2)
with pytest.raises(TypeError):
_ = b(1) <= b(2)
with pytest.raises(TypeError):
_ = b(1) > b(2)
with pytest.raises(TypeError):
_ = b(1) >= b(2)
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:12,代码来源:bag_test.py
示例4: test_supports_hash
def test_supports_hash():
assert hash(b(1, 2)) == hash(b(2, 1))
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例5: test_count_non_existent
def test_count_non_existent():
assert b().count(1) == 0
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例6: test_iter_multiple_elements
def test_iter_multiple_elements():
assert list(b(1, 2, 2)) in ([1, 2, 2], [2, 2, 1])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例7: test_not_contains
def test_not_contains():
assert 1 not in b(2)
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例8: test_length_duplicates
def test_length_duplicates():
assert len(b(1, 1)) == 2
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例9: test_length_multiple_elements
def test_length_multiple_elements():
assert len(b(1, 1, 2, 3)) == 4
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例10: test_remove_nonfinal
def test_remove_nonfinal():
assert b().add(1).add(1).remove(1) == b(1)
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例11: test_length_empty
def test_length_empty():
assert len(b()) == 0
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例12: test_repr_elements
def test_repr_elements():
assert repr(b(1, 2)) in ('pbag([1, 2])', 'pbag([2, 1])')
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例13: test_add
def test_add():
assert b().add(1) == b(1)
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例14: test_repr_empty
def test_repr_empty():
assert repr(b()) == 'pbag([])'
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例15: test_empty_truthiness
def test_empty_truthiness():
assert b(1)
assert not b()
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:3,代码来源:bag_test.py
示例16: test_hash_in_dict
def test_hash_in_dict():
assert {b(1,2,3,3): "hello"}[b(3,3,2,1)] == "hello"
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例17: test_count_unique
def test_count_unique():
assert b(1).count(1) == 1
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例18: test_remove_nonexistent
def test_remove_nonexistent():
with pytest.raises(KeyError) as excinfo:
b().remove(1)
assert str(excinfo.exconly()) == 'KeyError: 1'
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:4,代码来源:bag_test.py
示例19: test_count_duplicate
def test_count_duplicate():
assert b(1, 1).count(1) == 2
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
示例20: test_eq_empty
def test_eq_empty():
assert b() == b()
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:bag_test.py
注:本文中的pyrsistent.b函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论