fixtures

How can I use test-data/external variable in 'pytest.dependency'?

有些话、适合烂在心里 提交于 2020-08-10 19:10:08
问题 Below pytest code works fine, which increments value . import pytest pytest.value = 1 def test_1(): pytest.value +=1 print(pytest.value) def test_2(): pytest.value +=1 print(pytest.value) def test_3(): pytest.value +=1 print(pytest.value) Output: Prints 2 3 4 I don't want to execute test_2 , when value=2 Is it possible by pytest.dependency() ? If yes, how can i use variable value in pytest.dependency ? If not pytest.dependency , Any alternative ? or any better way of handling such scenarios ?

How to handle rerun in pytest with pytest_runtest_makereport fixture

梦想与她 提交于 2020-03-25 17:44:43
问题 I am using pytest-testrail in order to publish some python test cases to testrail. I have a couple test cases that are flaky and using --rerun in order to rerun the test cases that fail. After the rerun, some test cases will pass (meaning the case failed once and passed on the rerun), but pytest will publish the test as failed and pass both. //conftest.py file @pytest.hookimpl(trylast=True, hookwrapper=True) def pytest_runtest_makereport(item, call): report = (yield).get_result() if report

How to handle rerun in pytest with pytest_runtest_makereport fixture

六眼飞鱼酱① 提交于 2020-03-25 17:44:17
问题 I am using pytest-testrail in order to publish some python test cases to testrail. I have a couple test cases that are flaky and using --rerun in order to rerun the test cases that fail. After the rerun, some test cases will pass (meaning the case failed once and passed on the rerun), but pytest will publish the test as failed and pass both. //conftest.py file @pytest.hookimpl(trylast=True, hookwrapper=True) def pytest_runtest_makereport(item, call): report = (yield).get_result() if report