问题标签 [parametrized-testing]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 如何在计算 argvalues 之前在 pytest 中执行夹具?
我需要在夹具中创建数据库,在这个数据库中对数据进行一些操作(在代码中传递这部分以简化),并使用这个数据库中的行作为参数化测试的值。但是我不能在执行def之前强制pytest执行fixture来创建db。从 db 获取行,所以我的测试使用回溯“sqlite3.OperationalError:没有这样的表:simple_table”
Windows 10、Python 3.9、Pytest=6.2.5
dynamic - 如何从导入的辅助方法动态生成 pytest 参数化夹具?
我想要实现的基本上是这个,但是有一个类范围的参数化夹具。
问题是,如果我generate_fixture and inject_fixture
从帮助文件中导入方法 (),则注入夹具代码似乎被调用得太晚了。这是一个完整的工作代码示例:
如果我将生成和注入助手移动到他们自己的文件中(根本不更改它们),我会得到一个未找到固定装置的错误,即如果测试文件看起来像这样:
我在设置时遇到错误:E fixture 'myFixture' not found
后跟可用夹具列表(不包括注入的夹具)。
有人可以帮助解释为什么会这样吗?必须在每个测试文件中定义这些函数有点违背了这样做的全部意义(保持干燥)。