本文整理汇总了Python中factory.Sequence方法的典型用法代码示例。如果您正苦于以下问题:Python factory.Sequence方法的具体用法?Python factory.Sequence怎么用?Python factory.Sequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factory
的用法示例。
在下文中一共展示了factory.Sequence方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UssdSessionFactory
# 需要导入模块: import factory [as 别名]
# 或者: from factory import Sequence [as 别名]
def UssdSessionFactory(**kwargs):
# Uses Class Naming Convention because it's actually a delayed execution Class
def inner():
unique_name = Sequence(lambda n: f'FooSSD{n}')
ussd_menu = UssdMenuFactory(name=unique_name, display_key=unique_name)
return UssdSessionFactoryBase(ussd_menu=ussd_menu, **kwargs)
return inner()
示例2: Tweet
# 需要导入模块: import factory [as 别名]
# 或者: from factory import Sequence [as 别名]
def Tweet(session):
class _TweetFactory(factory.Factory):
class Meta:
model = model
id = factory.Sequence(lambda n: n)
return _TweetFactory
示例3: two_pages_of_invoices
# 需要导入模块: import factory [as 别名]
# 或者: from factory import Sequence [as 别名]
def two_pages_of_invoices(db, settings):
allowed_states = [Invoice.STATES.ISSUED, Invoice.STATES.PAID, Invoice.STATES.CANCELED]
return InvoiceFactory.create_batch(
settings.API_PAGE_SIZE * 2,
state=factory.Sequence(
lambda n: allowed_states[n % len(allowed_states)]
)
)
示例4: create_branch_by_slots
# 需要导入模块: import factory [as 别名]
# 或者: from factory import Sequence [as 别名]
def create_branch_by_slots(
cls, slots: Sequence[Slot], root: BaseSignedBeaconBlock = None, **kwargs: Any
) -> Iterable[BaseSignedBeaconBlock]:
if root is None:
root = cls()
parent = cls(
message__parent_root=root.message.hash_tree_root, message__slot=slots[0], **kwargs
)
yield parent
for slot in slots[1:]:
child = cls(message__parent_root=parent.message.hash_tree_root, message__slot=slot)
yield child
parent = child