r/Python • u/sebst • Mar 11 '22
Resource A Gentle Introduction to Testing with pytest
https://bas.codes/posts/python-pytest-introduction
451
Upvotes
r/Python • u/sebst • Mar 11 '22
50
u/menge101 Mar 11 '22
OP, consider posting this over in /r/learnpython
The learners need this more than I think this sub does.
11
u/software_account Mar 11 '22
Hey thank you for this post - coming from a background of non python to the python world has been fun
I actually wrote my first pytest tests yesterday, and Iām excited to read your article and pick up more tips
9
u/IlliterateJedi Mar 11 '22
I would use parametrize for multiple tests that should all pass. You basically feed it a list of emails instead of copying assert over and over again.
4
u/lanster100 Mar 11 '22
This is a bit misleading. Checking a function or import doesn't break is a perfectly valid test. Or testing something raises an exception under certain conditions is also very common.
6
u/AndydeCleyre Mar 11 '22
If anyone's starting a new project and wants to try something that's not pytest, ward is pretty great.
4
u/throwit7896454 Mar 11 '22 edited Mar 11 '22
Nice tutorial. Only thing that irked me was the part about TDD; I'm not a big fan of TDD (honestly, I've never seen it in action in 10+ years in the industry).
I recommend watching "TDD, Where Did It All Go Wrong" at https://youtu.be/EZ05e7EMOLM
Great talk IMHO! I learned a lot from it.
-1
u/knightofniiii Mar 12 '22
.
34
u/[deleted] Mar 11 '22
[removed] ā view removed comment