Skip to content

FlowerOda/pytest_auto_param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

说明

在pytest中使用参数化,方式如下:

import pytest

testparams = [
    (1, 2, 3, 4, 5, 6, 7),
    (7, 6, 5, 4, 3, 2, 1),
]

@pytest.mark.parametrize('a, b, c, d, e, f, g', testparams)
def test_many_args(a, b, c, d, e, f, g):
    assert d == 4

可以发现 在pytest.mark.parametrize写了参数名a,b,c,d,e,f,g, 在test_many_args中又写了a,b,c,d,e,f,g一遍,重复编写了参数,有什么方法可以去除呢? 经过探索,现已完成去除重复编写参数的功能。

import pytest

testparams = [
    (1, 2, 3, 4, 5, 6, 7),
    (7, 6, 5, 4, 3, 2, 1),
]

@pytest.auto_parametrize(testparams)
def test_many_args(a, b, c, d, e, f, g):
    assert d == 4

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages