本地pytest运行正常,GitHub Actions执行时报TypeError错误求助
pytest在GitHub Actions中执行失败(本地正常):dotenv相关问题排查
问题背景
本地运行pytest时所有测试正常通过,但在GitHub Actions中执行测试时失败。已完成以下配置:
- 在GitHub Secrets中配置了所需密钥
- 将
.env.test文件上传至GitHub仓库
目前怀疑是dotenv相关包的问题,或者存在其他配置疏漏,求排查思路。
已尝试的GitHub Actions配置
先后尝试了两种workflow.yml配置,均未解决问题:
配置方案1
# 填写第一种workflow配置内容
配置方案2
# 填写第二种workflow配置内容
错误日志
执行测试时触发以下错误:
TypeError: expected str, bytes or os.PathLike object, not NoneType
错误发生在pytest_django_dotenv插件的pytest_load_initial_conftests方法中,由os.path.join调用触发。
项目相关配置文件
requirements.txt
# 填写requirements.txt内容
pytest.ini
# 填写pytest.ini内容
settings.py(相关片段)
# 填写settings.py中与dotenv、测试相关的配置片段
本地环境
内容的提问来源于stack exchange,提问作者simon Shim
相关产品推荐
相关产品推荐

