Live data from Hacker News

Ask HN: What is your preferred Python 3 testing framework?

news.ycombinator.com

41–46 of 46 posts

Re: Ask HN: What is your preferred Python 3 testing framework?

#41

Earlier quoted context omitted.

what is "table driven testing"?

I've never heard of that term being used but parametrize helps in situations where: a) You have a slew of test inputs that all need to be tested through the same function, but you don't want to duplicate code. b) You want something like "test with every combination of [x,y,z] for parameter a and [j,k,l] for parameter b". This is probably what the grandparent is referring to. c)You have an even more complicated scheme…

Yes. But what's striking me is that one woud ever want to test only one input state. If I have to test function f(x) and see if its output is as expected, I always want to test many inputs (including "silly" ones like wrong type, nulls, extremes). Writing one test for each of them is absurd, just give a list of inputs, a list of expected outputs and check them all.

Re: Ask HN: What is your preferred Python 3 testing framework?

#42
post #9
post #2

pytest: https://docs.pytest.org/en/latest/ The dependency injection for fixtures is somewhat of a magical entity, but overall I've found it's the most efficient way to hammer out good tests on the standard unit/integration test spectrum. The default mode of operation doesn't even require importing pytest: Just write files named ending with `_test.py`, functions starting with `test`, and bare bones assertions. `yield_…

Pretty much anybody with big modern project i know in the industry is using pytest. It make the barrier of entry of writting tests much lower. Given how annoying it is to write test, i'd say making it even a tiny bit easier is a win. Plus fixtures scale better than tearUp and down.

Pytest with Mixer [1] really lowers the barrier to entry.

[1] https://mixer.readthedocs.io

Re: Ask HN: What is your preferred Python 3 testing framework?

#44
post #42
post #9

Earlier quoted context omitted.

Pretty much anybody with big modern project i know in the industry is using pytest. It make the barrier of entry of writting tests much lower. Given how annoying it is to write test, i'd say making it even a tiny bit easier is a win. Plus fixtures scale better than tearUp and down.

Pytest with Mixer [1] really lowers the barrier to entry. [1] https://mixer.readthedocs.io

Nice. How does it compare to factory boy ?

Re: Ask HN: What is your preferred Python 3 testing framework?

#45
post #39

Earlier quoted context omitted.

That's a different problem, though admittedly I was not very precise. (And by 'feels like typed', I meant feels closer to something like Haskell or OCaml than having eg Java as my target.) Even the best constructor magic in Python will struggle helping you verify the types of your functions.

Yes, without a test case to sensitize a run time check, no check. Both Haskell and Python have a sane approach to types, stuff in the middle not so much.

I don't know. OCaml is ok-ish.

Re: Ask HN: What is your preferred Python 3 testing framework?

#46
post #42

Earlier quoted context omitted.

Pytest with Mixer [1] really lowers the barrier to entry. [1] https://mixer.readthedocs.io

Nice. How does it compare to factory boy ?

Sorry for the late reply, I reckon I've more than halved the amount of set up code I have to write by switching to Mixer.
Post reply on HN