How to test your program in python

Правка en1, от Shaved_Chewbacca, 2021-03-13 06:44:51

Hey guys,

After watching this excellent video from Errichto, I decided to implement it to debug my python submissions. Code is available here.

It is quite simple really, just have a few programs:

gen.py:
Has a few function to generate random integers, list of integers and strings. Use this to generate test cases

timer.sh:
Should be used to check real time of execution

compare.sh:
Should be used to compare your solution vs a brute force (or a different implementation)

How to use it? Every time you have a bug, you do the following:
1. Add the file you want to test in that folder and call it tested.py
2. Code a brute force version and call it brute_force.py
3. Change the parameters in compare.sh : you want to chose the typical size of your "big" test cases and "small" test cases. This is explained in the video, but basically you want to test your solution against really big input obviously, but also smallish inputs that will be more likely to generate corner cases.

And that's it. Funny thing is that sometimes I will find my bug just by writing the code to generate test cases...

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Shaved_Chewbacca 2021-03-13 06:44:51 1351 Initial revision (published)