• Stas Bekman's avatar
    [testing] add dependency: parametrize (#6958) · b4a9c95f
    Stas Bekman authored
    unittest doesn't support pytest's super-handy `@pytest.mark.parametrize`, I researched and there are many proposed workarounds, most tedious at best. If we include https://pypi.org/project/parameterized/ in dev dependencies - it will provide a very easy to write parameterization in tests. Same as pytest's fixture, plus quite a few other ways. 
    
    Example:
    ```
    from parameterized import parameterized
    @parameterized([
        (2, 2, 4),
        (2, 3, 8),
        (1, 9, 1),
        (0, 9, 0),
    ])
    def test_pow(base, exponent, expected):
       assert_equal(math.pow(base, exponent), expected)
    ```
    (extra `self`var if inside a test class)
    
    To remind the pytest style is slightly different:
    ```
        @pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 6), ("6*9", 42)])
        def test_eval(test_input, expected):
    ```
    More examples here: https://pypi.org/project/parameterized
    
    May I suggest that it will make it much easier to write some types of tests?
    b4a9c95f
setup.py 6.14 KB