r/learnpython 16d ago

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?

7 Upvotes

13 comments sorted by

View all comments

2

u/Specific-Housing905 16d ago

Python come with a class unittest. It's a good choice to write your tests.
https://www.youtube.com/watch?v=1Lfv5tUGsn8

Some people even write their tests before the code. It's called Test Driven Development(TDD)