[docs] suggestion for http://docs.python.org/library/unittest.html#unittest.TestCase.assertRaises

Andrew Hammond andrew.george.hammond at gmail.com
Wed Mar 9 21:52:26 CET 2011


I suggest adding an example of using assertRaises to test a property:

class MyObject(object):
    @property
    def myProperty():
        raise Exception()

self.assertRaises(Exception, getattr, myObject, myProperty)

Rationale: the naive approach doesn't work and I spent a good half
hour figuring that out.

Andrew


More information about the docs mailing list