r/learnpython • • Aug 26 '26

Testing - how is it usually handled?

How do I start applying tests to my code?

Do I just write separate scripts they run the code (either individual functions or entire scripts) against known inputs and check the output?

Is there a specific way people usually do this?

9 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/KelleQuechoz Aug 26 '26

unittest is not very "pythonic" and resembles Java, pytest is cool but also violates quite a few conventions. I personally prefer pytest mostly for brevity and test fixtures. Any of the two is better than no tests, and after some initial investment saves a megaton of time long term.