Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

What is the real purpose of assert tests?

I'd like to know what's the real purpose, or quality of assert tests in python. How should you use them? As I've noticed, they won't always find a mistake.

For example, let's say that somewhere in my code I pick a random number from range 0-100 (it should be 1-100). To be sure I run assert test that checks if my number is between 1 and 100. If I run this test once, it's really only 1% (or even less) chance that my test fails, because the generated number is 0. In real case situation, to really find out bugs, or mistakes in the code, should I run this kind of test hundreds of times?