python - Pytest:无论标记如何,如何在所有其他测试之后运行一些测试
问题描述
我有带有标记的测试组:“烟雾”
@pytest.mark.smoke
def test_add_data_source():
.....
@pytest.mark.smoke
def test_del_data_source():
.....
我使用以下命令开始测试:
pytest --strict -s -v -m smoke --alluredir=allure-results
没关系,一切正常。
现在我需要在所有测试完成后将我的 Allure 文件复制到 Allure Report 服务到 Kubernetes 中。这需要在任何情况下运行,与使用的标记无关。我使用了拆解语法:
@pytest.fixture(scope="module",autouse=True)
def global_fixture():
yield
send_result()
但在这种情况下,它不会为组中的最后一个测试发送 Allure 文件。但是,如果我使用这样的附加测试 - 它会起作用:
@pytest.mark.smoke
def test_global_fixture():
send_result()
但无论标记的任何过滤器如何,我都需要运行此测试。在这两个命令的所有其他测试之后应运行 at:
pytest --strict -s -v -m smoke --alluredir=allure-results
pytest --strict -s -v --alluredir=allure-results
我怎样才能做到这一点?
解决方案
推荐阅读
- php - 在我的数组 API 中获取博客类别时遇到问题
- javascript - 剑道网格过滤器定制
- pandas - 加快 pandas 到 numpy 的转换
- json - 在合约 SmartContract 中找不到函数 uploadData - Hyperledger Fabric
- python - 为什么前馈神经网络中的简单二元分类会失败?
- reactjs - 为什么排序时元素不在正确的位置?
- ruby-on-rails - 控制器中的 ActionController::UnknownFormat (#index)
- javascript - 从动态添加的 onClick 事件调用时,Javascript CSS 显示不起作用
- asp.net-core - 特定 cookie 的 asp.net 核心 Cookie 策略选项覆盖
- go - 如何在 Go 中使用 Minio 预签名 URL