【发布时间】:2020-05-30 09:45:51
【问题描述】:
我正在为 webapp 编写测试,有时需要一段时间才能在生产服务器上看到更改。我不希望这些测试失败,但我也不想忽略它们。因此,我想在针对生产服务器运行时将此类测试标记为 xfail,但我无法访问标记中可以在测试用例内部访问的选项对象。一旦这些测试通过 XPASS,标记就会被删除。这些测试也不应该是
有没有可能这样做?
@pytest.mark.xfail(
options.getini("base_url") == options.getini("production_server"),
reason="Change not yet deployed to the production server")
def test_apidoc(self, request, base_url):
我能看到的唯一解决方法是:
def test_apidoc(self, request, base_url):
not_production_ready(request)
if request.config.getoption("base_url") == request.config.getini("production_server"):
pytest.xfail("Changes not yet deployed to the production")
pass
但这会立即忽略测试。
【问题讨论】:
标签: python selenium-webdriver pytest