smithy
smithy

Reputation: 417

Display actual value if a test fails

Say I have a test like this:

self.assertTrue( car.color == 'blue') 

I run it with

nosetests test_car.py -x -v --stop

If it fails, I would like it to print out the actual value of car.color. Is there a way to do that?

Upvotes: 1

Views: 51

Answers (1)

Jason S
Jason S

Reputation: 13779

That's where you need to use self.assertEqual(car.color, 'blue'). assertTrue is better for checking boolean properties or expressions that aren't simple equality.

Upvotes: 5

Related Questions