On Mon, Jan 03, 2011 at 08:34:07PM +0200, Michael Goldish wrote: > +# Exception context information: > +# ------------------------------ > +# Every function can have some context string associated with it. > +# The context string can be changed by calling context(str) and cleared by > +# calling context() with no parameters. > +# get_context() joins the current context strings of all functions in the > +# provided traceback. The result is a brief description of what the test was > +# doing in the provided traceback (which should be the traceback of a caught > +# exception). I am sure people will eventually forget to call context() to clear previous context calls, and people won't notice until an actual error is raised on another section. What about a decorator like: @context("hello") def a() ... That would set/clear the context automatically when the function is called/returns? > +# > +# For example: assume a() calls b() and b() calls c(). > +# > +# def a(): > +# error.context("hello") > +# b() > +# error.context("world") > +# get_context() ----> 'world' > +# > +# def b(): > +# error.context("foo") > +# c() > +# > +# def c(): > +# error.context("bar") > +# get_context() ----> 'hello --> foo --> bar' Above sample code is a good candidate to be in a doctest string or unit test, isn't it? -- Eduardo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html