本文整理匯總了Python中nose.plugins.xunit.Xunit.stopTest方法的典型用法代碼示例。如果您正苦於以下問題:Python Xunit.stopTest方法的具體用法?Python Xunit.stopTest怎麽用?Python Xunit.stopTest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nose.plugins.xunit.Xunit
的用法示例。
在下文中一共展示了Xunit.stopTest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run_tests
# 需要導入模塊: from nose.plugins.xunit import Xunit [as 別名]
# 或者: from nose.plugins.xunit.Xunit import stopTest [as 別名]
def run_tests(spider, output_file, settings):
"""
Helper for running test contractors for a spider and output an
XUnit file (for CI)
For using offline input the HTTP cache is enabled
"""
settings.overrides.update({
"HTTPCACHE_ENABLED": True,
"HTTPCACHE_EXPIRATION_SECS": 0,
})
crawler = CrawlerProcess(settings)
contracts = build_component_list(
crawler.settings['SPIDER_CONTRACTS_BASE'],
crawler.settings['SPIDER_CONTRACTS'],
)
xunit = Xunit()
xunit.enabled = True
xunit.configure(AttributeDict(xunit_file=output_file), Config())
xunit.stopTest = lambda *x: None
check = CheckCommand()
check.set_crawler(crawler)
check.settings = settings
check.conman = ContractsManager([load_object(c) for c in contracts])
check.results = xunit
# this are specially crafted requests that run tests as callbacks
requests = check.get_requests(spider)
crawler.install()
crawler.configure()
crawler.crawl(spider, requests)
log.start(loglevel='DEBUG')
# report is called when the crawler finishes, it creates the XUnit file
report = lambda: check.results.report(check.results.error_report_file)
dispatcher.connect(report, signals.engine_stopped)
crawler.start()