# pytest_auto_param **Repository Path**: hxtm/pytest_auto_param ## Basic Information - **Project Name**: pytest_auto_param - **Description**: 避免在pytest.mark.parametrize参数化中编写重复参数 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-19 - **Last Updated**: 2021-09-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 说明 在pytest中使用参数化,方式如下: ```python 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一遍,重复编写了参数,有什么方法可以去除呢? 经过探索,现已完成去除重复编写参数的功能。 ```python 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 ``` 参考 https://github.com/mgeier/pytest-auto-parametrize