我有一堆需要运行的测试方法,然后在每次测试后我想在其他地方更新我的结果。
这就是我所拥有的:
@pytest.mark.testcasename('1234')
@pytest.mark.parametrize('lang',
["EN", "FR"])
def test_text(self, request, base_url, lang):
testrail_conn = TestrailHelper()
test_case_id = request.node.get_marker("testcasename").args[0]
base_url = base_url.replace("testEN", "testFR") if lang == "FR" else base_url
self.navigate(base_url)
self.wait_for_page_loaded()
results = self.check_text(lang)
try:
assert results
testrail_conn.update_test_status(test_case_id, test_result=1)
except AssertionError:
testrail_conn.update_test_status(test_case_id, test_result=5)
我的问题是我希望 update_test_status 位于拆卸装置中,我可以将我的 test_result 传递给它。这样我就不需要为每个测试方法编写相同的代码..
有任何想法吗?
谢谢
最佳答案
您可以在 request
上存储一些东西对象,例如在 request.node
- 见 the docs .或者,您可以使用测试中的 fixture (作为参数),并在那里存储一些东西 - 或者让 fixture 返回/产生某种数据结构来存储东西。
关于python - 是否可以将参数传递给python中的拆卸 fixture ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35320569/