0

I have gone through many source code of functional test cases written in python. Many of the code uses assert for testing equality, why so?

0

1 Answer 1

3

In most test runners, a test failure is indicated by raising an exception - which is what the assert() function does if its argument evaluates to False.

Thus assert(1 == 0) will fail, and abort that specific test with an AssertionError exception. This is caught by the test framework, and the test is marked as having failed.

The framework/test-runner then moves on to the next test.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.