unit testing properties
Duncan Booth
duncan at NOSPAMrcp.co.uk
Fri Jan 18 06:57:37 EST 2002
"Mark McEahern" <mark at mceahern.com> wrote in
news:mailman.1011319347.7193.python-list at python.org:
> def testSetter(self):
> f = Foo()
> self.assertRaises(AttributeError, f.bar...
>
> That's where I get stopped. The second param to assertRaises is
> supposed to be a callable object--but I want to test a setter. Hmm,
> any ideas?
How about using setattr?
def testSetter(self):
f = Foo()
self.assertRaises(AttributeError, setattr, f, 'bar', 42)
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list