Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news.astraweb.com!border6.newsrouter.astraweb.com!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: unittest: assertRaises() with an instance instead of a type References: <4f735345$0$29981$c3e8da3$5496439d@news.astraweb.com> X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Date: Thu, 29 Mar 2012 12:55:13 +1100 Message-ID: <87mx70f9xa.fsf@benfinney.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:J6byomVBKTQlNo1e+Sfyugt1CuQ= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 15 Organization: Unlimited download news at news.astraweb.com NNTP-Posting-Host: 95543a8f.news.astraweb.com X-Trace: DXC=hedA5gb]3U@I]J2Y9=AF]JL?0kYOcDh@JN7:H2`MmAUCL3cA6h=hU\J]G;2>V^?kWCbEW9A[5UK?ENZ[SL`C\KgC^I;=]QAeBAH Xref: csiph.com comp.lang.python:22322 Steven D'Aprano writes: > (By the way, I have to question the design of an exception with error > codes. That seems pretty poor design to me. Normally the exception *type* > acts as equivalent to an error code.) Have a look at Python's built-in OSError. The various errors from the operating system can only be distinguished by the numeric code the OS returns, so that's what to test on in one's unit tests. -- \ “In the long run, the utility of all non-Free software | `\ approaches zero. All non-Free software is a dead end.” —Mark | _o__) Pilgrim, 2006 | Ben Finney