News for hackers. Stuff that matters.
Re:Stop requiring only one assertion per unit test: Multiple... by lifeisstillgood on Saturday November 05, 2022 @09:10AM (#33481079)
Yes parameterised testing. Just all the packages i have tried seemed to make it awkward to impossible - hence metaclasses
Re:Stop requiring only one assertion per unit test: Multiple... by ckp95 on Saturday November 05, 2022 @09:49AM (#33481455)
Does this do what you want?

https://github.com/ckp95/pytest-parametrize-cases

    @parametrize_cases(
        Case("handle null", age=None, x="foobar"),
        Case("don't allow under 13s", age=11, x="foobar"),
        Case("or old age pension", age=77, x="wobble"),
        ... # as many as you want
    )
    def test_lots_of_ways_to_fail(age, x):
        with pytest.raises(ValueError):
            function_under_test(age, x)
Re:Stop requiring only one assertion per unit test: Multiple... by lifeisstillgood on Saturday November 05, 2022 @02:17PM (#33484095)
Just wanted to pop in and say ckp95 actually mailed me this reply in case I missed it. The extra effort kinda restored my faith in humanity - giving a shit about strangers problems matters these days. Nice one.

cf https://youtu.be/wUyI3ssmj_U