pytest conftest定义一个fixtrue获取测试环境地址

方便全局切换地址

复制代码
@pytest.fixture()
def config():
    data = {
        '测试环境': {
            'A环境': '127.0.0.1',
            'B环境': '127.0.0.2',
            'C环境': '127.0.0.3',
            'D环境': '127.0.0.4'
        },
    }


    return data.get('测试环境', {}).get('A环境')

import pytest

def test_case001(
        config
    ):

    url = 'http://'+str(config)+':8080/api/user/login'
    print('\n', url)


if __name__ == '__main__':
    pytest.main(['s', 'v', 'test_case6.py'])
    pass
相关推荐
在世修行3 小时前
干货:pytest
pytest·fixture·pytest assert
全栈练习生6 小时前
AI Agent 沙箱
python·ai
SEO_juper7 小时前
用 Python 写一个 GEO 可见性检查脚本:你的网站现在能被 AI 引用吗
开发语言·人工智能·爬虫·python·seo·外贸独立站
用户8356290780518 小时前
使用 Python 对 Excel 工作表进行排序
后端·python
for_ever_love__8 小时前
MySQL 全文索引实战:FULLTEXT、ngram 中文分词与 MATCH AGAINST 到底该怎么用
java·python·mysql·全文检索·分词·索引·ngram
用户8356290780518 小时前
使用 Python 合并 PowerPoint 演示文稿
后端·python
weixin_461769409 小时前
VS Code 中创建 Jupyter 文件(.ipynb)
ide·python·jupyter
2601_966949659 小时前
多市场量化策略的数据接口应该如何设计:从数据层架构到策略接入
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
全栈弄潮儿9 小时前
Python实战第1期:Python环境搭建与第一个程序
python
心易行者9 小时前
Agent应用+API端点商业化进阶实战:从单体智能体到可付费调用的API全流程
运维·服务器·人工智能·python·apache