Hello,
<div><br></div><div>We have a somewhat interesting opportunity to build meaningful error messages whenever a test fails.</div><div>The way we write tests, we have a single fixture per test class. We are naming our classes things like: </div>
<div>WhenSomethingIsTrue, and we are naming our functions like: should_cause_something_to_happen. </div><div>I&#39;d like to know if there is a way, after a test method runs, whether to see whether it failed and to then </div>
<div>look at the name of the class (and its sub-classes) and the function to spit out a short story about what</div><div>the context of the failure was. With my example:</div><div><br></div><div>When something is true.</div>
<div>It should cause something to happen.</div><div><br></div><div>In our particular environment, we often will create a subclass for each branch through the code. While</div><div>this is a lot of work, it makes it easier to limit the number of assertions in each test method. It also</div>
<div>makes naming like this possible. The good thing is all these subclasses are the result of verifying</div><div>different behavior, not just because their&#39;s an if/else statement. Nevertheless, these hierarchies can</div>
<div>get quite long and it becomes difficult to ascertain the context in which the failure occurred. If we</div><div>could get a short printout saying the conditions, it would make fixing the bug a no-brainer most of</div>
<div>the time. The good thing is we already are inheriting from a subclass of unittest.TestCase, called</div><div>UnitTestCase. If there was a way to achieve this functionality, I could slip it in there and no one would</div>
<div>need to change a line of code. This could be a major productivity booster.</div><div><br></div><div>Thanks for any feedback,</div><div>Travis Parks</div>