Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
使用固定装置返回值作为 mark.parametrize() 中的值
我的问题是 是否可以使用夹具的返回值作为参数化中的值 问题是 我想动态获取参数化的可能值 例如 虚拟服务器上的可用系统 当其中一个设备创建虚拟服务器时 我可以访问这些 测试看起来像这样 伪代码 conftest py pytest fixt
python
Pytest
如何针对不同版本的 python 运行 py.test?
是否可以运行py test使用不带插件的不同版本的python 例如xdist or tox 最简单的方法是直接运行 pytest 模块 m 例如 python2 6 m pytest 请注意 您必须安装 pytest那个版本Python
python
Pytest
使用 unittest.mock 在 Python 中模拟 os.remove
我该如何嘲笑os remove with unittest mock 我的尝试 使用pytest def test patch remove with patch os remove remove foo 给出错误 remove foo E
python3x
unittesting
mocking
Pytest
如何使用 pytest 测试无限 while 循环
我目前正在编写一个与bamboo 构建服务器交互的小库 测试是使用 pytest 完成的 我陷入了以下问题 我想测试一个 while 循环 该循环运行直到满足某些状态 阅读 pytest 文档 我尝试 模拟 monkeypatch 状态 但
python
unittesting
mocking
Pytest
monkeypatching
Pytest版本冲突错误
更新 Debian Jessie 后 pytest 无法工作 py test Traceback most recent call last File usr bin py test line 5 in
python
Debian
Pytest
sys.path 包括 py.test rootdir 以使测试相对于项目根目录导入
我在 pytest 中遇到问题 未将我的项目 rootdir 包含在 sys path 列表中 相反 它包含默认情况下测试所在的目录 这是我的项目结构 proj setup py mypackage init py a py tests t
python
Pytest
pytest:无法模拟我的班级的 __init__
我有一个习惯Db类 具有基本操作 我正在尝试围绕它编写测试 在 init 在我的班级中 我正在连接到我想避免的实际数据库 因为我只是编写单元测试 不需要连接到实际数据库 这是我的代码 mock patch mydb Db pytest ma
python
unittesting
Pytest
有没有办法覆盖 pytest (python) 中的默认断言?
我想在每次调用断言时将一些信息记录到文件 数据库中 有没有办法在每次调用断言时覆盖断言或注册某种回调函数来执行此操作 问候 沙拉德 尝试超载AssertionError代替assert 原始断言错误可在异常模块 https docs pyt
python
Pytest
pytest django:无法访问固定装置拆卸中的数据库
我需要在使用夹具后显式删除它 我知道 pytest django 默认情况下会在拆卸时删除所有对象 但在这种特殊情况下 我需要手动执行此操作 然而 虽然我的测试被标记为pytest mark django db 我能够创建一个夹具 但在经过
django
Pytest
pytestdjango
即使有标记,pytest-django 也不允许数据库访问
我很难找出我的设置出了什么问题 我正在尝试测试登录视图 无论我尝试什么 我都会得到 Database access not allowed use the django db mark or the db or transactional
django
Pytest
pytestdjango
如何将命令行参数从 pytest 传递到代码
我正在尝试将参数从 pytest 测试用例传递到正在测试的模块 例如 使用 main pyPython 样板 https www python boilerplate com py3 argparse pytest 我可以从命令行运行它 p
python3x
Pytest
argparse
如何在测试 FastAPI 应用程序时触发生命周期启动和关闭?
作为 FastAPI 的新手 我正在努力测试比我在教程中看到的稍微困难的代码 我用fastapi cache模块和Redis是这样的 from fastapi import Depends FastAPI Query Request fro
python
Testing
Redis
Pytest
FastAPI
在同一模块中使用unittest.mock的补丁,通过“__main__.imported_obj”修补时得到“没有该属性”
我的任务本来应该很简单 但它却困扰了我一段时间 我在尝试着patch导入到当前模块中的对象 根据答案Python 中的模拟修补 from import 语句 https stackoverflow com questions 1135138
python
unittesting
mocking
Pytest
pythonunittestmock
pytest从不同的测试文件独立导入相同的模块
以下主题模块包含两个函数 其中之一操作全局变量 mod py def global setter global x x 123 print setter x x def global getter print getter x x 每个功能
python
Pytest
pythonimport
如何将配置变量发送到 py.test 测试?
我有一个测试套件需要与多个后端一起运行 但这不是一个简单的参数化测试 因为它适用于整个套件 多个文件 模块 我可以通过环境控制运行 但我想知道 py test 是否有更清晰的方式来表达这一点 也就是说 我正在寻找这样的东西 py test
python
unittesting
Pytest
Pytest 不选取类内的测试方法
一直使用Pythonunittest2 并且刚刚开始迁移到pytest 当然 我试图进行比较 但我无法弄清楚的一件事是 Question为什么 Pytest 不选择 测试 类中定义的测试方法 什么对我有用 login test py imp
python
python3x
Pytest
使用 py.test 在 Python 中测试正则表达式
正则表达式对我来说仍然是一门黑暗艺术 但我认为这是需要练习的事情之一 因此 我更关心能够生成 py test 函数来显示我的正则表达式失败的地方 我当前的代码是这样的 my regex re compile
python
unittesting
python3x
Pytest
如何将 pytest-aiohttp 装置与范围会话一起使用
我正在尝试为 aiohttp 应用程序编写测试 我正在使用 pytest aiohttp 插件 我的目的是在第一次测试执行之前初始化并运行应用程序一次 并在所有测试完成后拆除 pytest aiohttp 固定装置 例如 loop test
python
Pytest
fixtures
aiohttp
py.test 无法从 conftest 正确导入模块 - 失败并显示 ConftestImportFailure: ModuleNotFound
pytest无法导入模块 即使这些模块在普通模式下导入正常python口译员 特别是从以下位置导入的模块conftest未能解决 当 pytest 尝试重写模块中的断言信息时 会引发 ImportErrori 回溯示例 test sessi
python
Pytest
为 sqlalchemy 应用程序编写 pytest
我正在尝试将单元测试转换为 py 测试 我正在使用单元测试示例 class TestCase unittest TestCase def setUp self app config TESTING True app config CSRF
python
sqlalchemy
Pytest
«
1
2
3
4
5
6
7
8
...22
»