本文整理汇总了Python中tracker.Tracker.wrapped_setups方法的典型用法代码示例。如果您正苦于以下问题:Python Tracker.wrapped_setups方法的具体用法?Python Tracker.wrapped_setups怎么用?Python Tracker.wrapped_setups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracker.Tracker
的用法示例。
在下文中一共展示了Tracker.wrapped_setups方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tokeniser
# 需要导入模块: from tracker import Tracker [as 别名]
# 或者: from tracker.Tracker import wrapped_setups [as 别名]
class Tokeniser(object):
"""Endpoint for tokenising a file"""
def __init__(self, default_kls='object', with_describe_attrs=True, import_tokens=None, wrapped_setup=False):
self.default_kls = default_kls
self.import_tokens = import_tokens
self.wrapped_setup = wrapped_setup
self.with_describe_attrs = with_describe_attrs
########################
### TRANSLATE
########################
def translate(self, readline, result=None, no_imports=None):
# Tracker to keep track of information as the file is processed
self.tokens = Tokens(self.default_kls)
self.tracker = Tracker(result, self.tokens, self.wrapped_setup)
# Add import stuff at the top of the file
if self.import_tokens and no_imports is not True:
self.tracker.add_tokens(self.import_tokens)
# Looking at all the tokens
with self.tracker.add_phase() as tracker:
for tokenum, value, (_, scol), _, _ in generate_tokens(readline):
self.tracker.next_token(tokenum, value, scol)
# Add attributes to our Describes so that the plugin can handle some nesting issues
# Where we have tests in upper level describes being run in lower level describes
if self.with_describe_attrs:
self.tracker.add_tokens(self.tracker.make_describe_attrs())
# If setups should be wrapped, then do this at the bottom
if self.wrapped_setup:
self.tracker.add_tokens(self.tracker.wrapped_setups())
# Add lines to bottom of file to add __testname__ attributes
self.tracker.add_tokens(self.tracker.make_method_names())
# Return translated list of tokens
return self.tracker.result