[TIP] unittest2 assertRaises failure message

Olemis Lang olemis at gmail.com
Sun Jan 13 19:40:52 PST 2013


Hi all !
:)

The body of a `unittest2` test case looks like this ...

{{{
#!python

# ------8<--- Further code omitted ---8<------
    for x in seq:
        # ------8<--- Further code omitted ---8<------
        with self.assertRaises(MyException) as cm:
            # Assertions et al.

}}}

As you can see there's a chance for assertRaises to fail and as a
consequence a message like «AssertionError: MyException not raised» is
included in ouput . That's not informative enough *in this case* since
I'd like to know e.g. the exact value of x .

Q:
  - Is there a chance to customize `assertRaises` failure message ?
  - Is there any chance for e.g. dumping `locals()` ?
  - Can `unittest2` be helpful somehow ?
  - Any other suggestions ?

Any feedback will be welcome . Thanks in advance .


-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:



More information about the testing-in-python mailing list