當前位置: 首頁>>代碼示例>>Python>>正文


Python Tracker.wrapped_setups方法代碼示例

本文整理匯總了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
開發者ID:benauthor,項目名稱:nose-of-yeti,代碼行數:42,代碼來源:tokeniser.py


注:本文中的tracker.Tracker.wrapped_setups方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。