주어진 몇 가지 예제 코드를 찾을 수 있습니다. 마지막에, 당신의 분해하기 전에 그런 다음의 tearDown 당신이 경우 논리의 어떤 종류를 포함 할 필요가
# Curl call to SauceLabs API to report Job Result
def set_test_status(self, jobid, passed):
base64string = base64.encodestring('%s:%s' % (config['username'], config['access-key']))[:-1]
body_content = json.dumps({"passed": passed})
connection = httplib.HTTPConnection("saucelabs.com")
connection.request('PUT', '/rest/v1/%s/jobs/%s' % (config['username'], jobid),
body_content,
headers={"Authorization": "Basic %s" % base64string})
result = connection.getresponse()
return result.status == 200
을 포함해야합니다. 나는 이런 식으로했다 (그리고 그것은 작동) 나를 위해 속임수를 썼는지
def tearDown(self):
# sys.exc_info should be (None, None, None) if everything is OK, it fills with some values if something went wrong
# This if reports to Sauce Labs the outcome of the Test where True = Pass and False = Failed
if sys.exc_info() == (None, None, None):
self.set_test_status(self.driver.session_id, True)
else:
self.set_test_status(self.driver.session_id, False)
self.driver.quit()
self.assertEqual([], self.verificationErrors)
출처
2013-12-02 17:43:30
Gus
나는 그것이 대부분의 테스트 프레임 워크의 표준 절차를 다음과 생각했을 것이다 : 예외 또는이없는 경우는 패스입니다 * 명시 적으로 강제로 전달 * 예외가 있거나 명시 적으로 강제로 실패하면 실패합니다. – Arran