3 ms·
isn't this just a parametrized test? or do you want to generate the test cases automatically like in property-based testing?
by _dain_ 4y ago
isn't this just a parametrized test? or do you want to generate the test cases automatically like in property-based testing?
- lifeisstillgood 4y agoYes parameterised testing. Just all the packages i have tried seemed to make it awkward to impossible - hence metaclasses
- deleted 4y ago[deleted]
- ckp95 4y agoDoes this do what you want? https://github.com/ckp95/pytest-parametrize-cases 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)
- lifeisstillgood 4y agoJust 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 https://youtu.be/wUyI3ssmj_U