In article <c38a5bb4-6087-453c-8873-f193927fd...@d8g2000yqf.googlegroups.com> Inyeol <inyeol....@gmail.com> wrote: [snippage below] >import unittest >class C(): > def __getattr__(self, name): > raise AttributeError >class Test(unittest.TestCase): > def test_getattr(self): > c = C() > self.assertRaises(AttributeError, c.foo) >unittest.main() >----------------------------------------------------- >... or am I missing something obvious?
As Benjamin Peterson noted, the error occurs "too soon", so that the unittest code never has a chance to see it. The "something obvious" is to defer the evaluation just long enough: self.assertRaises(AttributeError, lambda: c.foo) -- In-Real-Life: Chris Torek, Wind River Systems Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603 email: gmail (figure it out) http://web.torek.net/torek/index.html
-- http://mail.python.org/mailman/listinfo/python-list