当前位置: 首页>>代码示例>>Python>>正文


Python Driver.get_test_plan方法代码示例

本文整理汇总了Python中driver.Driver.get_test_plan方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.get_test_plan方法的具体用法?Python Driver.get_test_plan怎么用?Python Driver.get_test_plan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在driver.Driver的用法示例。


在下文中一共展示了Driver.get_test_plan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import get_test_plan [as 别名]
class Listener:
	'''
	http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-listener-interface
	'''

	ROBOT_LISTENER_API_VERSION = 2 # Do Not Change This

	def __init__(self, build, environment):
		'''
		Parameters come from invoking command i.e. variables seprated by ":" in pybot command

		Args:
			build (str): build name
			environment (str): environment name
		'''
		settings = read_config('localbugz')
		username = settings['username']
		# login of the manager
		# todo: omit it, make driver api more consistent
		self.MANAGER = username

		testopia_url = settings['url']
		self.driver = Driver(testopia_url, username, settings['password'])
		self.build = build
		self.environment = environment
		self.driver.set_build_and_environment(build, environment)
		self.no_run_id = False

		self.conn = Connector(settings['database'])

	def start_suite(self, name, attrs):
		'''
		http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#listener-interface-method-signatures
		'''
		doc = attrs['doc']	# doc is <type 'unicode'>
		self.absolute_path = attrs['source']
		tests = attrs['tests']	# empty suits return empty list
		if tests:	# empty list -> False	any list other than empty list -> True
			if not self.conn.is_exported_suite(self.absolute_path):
				# This is the first time this suite is executed and,
				plan_name = get_plan_name(self.absolute_path)
				plan_id = None
				if self.conn.is_exported_plan(plan_name):
					# a plan is already created for the suites in this directory
					plan_id = self.conn.get_PlanID(plan_name)
				else:
					# no plan has been created earlier that this suite belong to
					# plans are not created for every new suite but for new suites
					# with different top level directory
					plan_id = self.driver.create_plan(plan_name)['plan_id']
					self.conn.insert_plan_as_exported(plan_name, plan_id)
				# For every new suite a Run will be created:
				run = self.driver.create_run(plan_id, str(self.build), self.MANAGER, summary=str(doc))
				self.run_id = run['run_id']
				self.conn.insert_as_exported(self.absolute_path, self.run_id)
			else:
				# This is not a new suite and a Run already exist for it
				self.run_id = self.conn.get_RunID(self.absolute_path)

	def start_test(self, name, attrs):#todo: update doc string
		'''case [Documentation] must start with "case_id;;"
		'''
		self.newCase = False
		caselongname = attrs['longname'] #todo: should change to 'id', should work in new version of robot
		
		if not self.conn.is_exported_case(caselongname, self.absolute_path):
			# This case is newly added to the test suite or is the first time executed
			self.newCase = True
			self.actions = []
			self.results = []
			try:
				summary = name + ' - ' + attrs['doc']
				plan = self.driver.get_test_plan(self.run_id)
				case = self.driver.create_case(priority='Normal', summary=summary, plans=plan,
				 tester=self.MANAGER)
				self.case_id = case['case_id']	#todo: should case_id be class variable or local is ok?
				self.driver.add_to_run(self.case_id, self.run_id)
				self.conn.insert_case_as_exported(caselongname, self.absolute_path, self.case_id)
			except:
				print "Unexpected error in new TestCase processing:", sys.exc_info()[0]
				raise
		else:
			self.case_id = self.conn.get_CaseID(caselongname, self.absolute_path)

		self.driver.caserun_running(self.run_id, self.case_id)

	def end_test(self, name, attrs):
		status = attrs['status']

		if status == 'PASS':
			self.driver.caserun_passed(self.run_id, self.case_id)
		elif status == 'FAIL':
			self.driver.caserun_failed(self.run_id, self.case_id)
		
		if self.newCase:
			# Steps and results for new Case will be collected in a list by using start_keyword method
			# list will be converted to a string with a html list format and inserted in Testopia
			def make_html_list(elements):
				'''
				converts a list of "<li>...</li>" strings (i.e. collected list) to
#.........这里部分代码省略.........
开发者ID:mohzah,项目名称:rotopia,代码行数:103,代码来源:listener.py


注:本文中的driver.Driver.get_test_plan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。