相关疑难解决方法(0)

pytest在辅助函数中断言内省

pytest确实很棒,assert introspection因此很容易找到字符串的差异,特别是如果差异在白色空间中.现在我使用了一个稍微复杂的测试助手,我在许多测试用例中重用了它.帮助器也有自己的模块,对于那个模块,我想添加断言内省.

helpers.py:

...
def my_helper():
    assert 'abcy' == 'abcx'
Run Code Online (Sandbox Code Playgroud)

test_mycase.py:

from .helpers import my_helper


def test_assert_in_tc():
    assert 'abcy' == 'abcx'


def test_assert_in_helper():
    my_helper()
Run Code Online (Sandbox Code Playgroud)

测试报告显示测试中断言的有用信息,但是not for asserts within the helper:

=============================================================== FAILURES ================================================================
___________________________________________________________ test_assert_in_tc ___________________________________________________________

    def test_assert_in_tc():
>       assert 'abcy' == 'abcx'
E       assert 'abcy' == 'abcx'
E         - abcy
E         ?    ^
E         + abcx
E         ?    ^

tests/test_pytest_assert.py:9: AssertionError
_________________________________________________________ test_assert_in_helper _________________________________________________________

    def test_assert_in_helper():
>       my_helper()

tests/test_pytest_assert.py:13: 
_ _ _ _ _ …
Run Code Online (Sandbox Code Playgroud)

python pytest

14
推荐指数
1
解决办法
1256
查看次数

如何删除 PyCharm 中的 pytest --no-header --no-summary -q 参数?

我看到运行默认设置pytest配置的参数如下:

Launching pytest with arguments payments/tests/test_edd_countries.py --no-header --no-summary -q in payments/tests
Run Code Online (Sandbox Code Playgroud)

我想专门删除所有这些参数:

--no-header --no-summary -q 
Run Code Online (Sandbox Code Playgroud)

Runtime configuration鉴于inEdit Configurations甚至没有显示它们,如何实现这一点?

在此输入图像描述

python pytest pycharm

7
推荐指数
1
解决办法
1209
查看次数

标签 统计

pytest ×2

python ×2

pycharm ×1