python3 how to set test passed in unittest

Viewed 155

I have a test with a loop checking some condition.

I want this loop to break and test to be passed if condition is true, otherwise I want to mark test as failed after loop ended.

here is the code

while time.time() < timeout:
    if condition:
        self.assertTrue(True)
self.fail()

but this solution is not working, loop is not breaking with the assert, why so?

2 Answers
Related