python中pytest教程_Pytest权威教程-更改标准(Python)测试发现

更改标准(Python)测试发现

在测试收集过程中忽略路径

通过--ignore=path在cli上传递选项,可以轻松地在收集过程中忽略某些测试目录和模块。pytest允许多个 --ignore选项。例:

tests/

|-- example

| |-- test_example_01.py

| |-- test_example_02.py

| '-- test_example_03.py

|-- foobar

| |-- test_foobar_01.py

| |-- test_foobar_02.py

| '-- test_foobar_03.py

'-- hello

'-- world

|-- test_world_01.py

|-- test_world_02.py

'-- test_world_03.py

现在,如果你调用pytest使用,你会发现只收集测试模块,这不符合指定的模式:--ignore=tests/foobar/test_foobar_03.py --ignore=tests/hello/pytest

=========================== test session starts ============================

platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y

rootdir: $REGENDOC_TMPDIR, inifile:

collected 5 items

tests/example/test_example_01.py . [ 20%]

tests/example/test_example_02.py . [ 40%]

tests/example/test_example_03.py . [ 60%]

tests/foobar/test_foobar_01.py . [ 80%]

tests/foobar/test_foobar_02.py . [100%]

========================= 5 passed in 0.02 seconds =========================

该--ignore-glob选项允许忽略基于Unix Shell样式通配符的测试文件路径。如果要排除测试模块与终端_01.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值