Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'context': 0.05; 'executed': 0.07; 'raised': 0.07; 'raises': 0.07; 'stops': 0.07; 'block.': 0.09; 'oserror': 0.09; 'cc:addr:python- list': 0.10; '*should*': 0.16; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'testing': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'reaches': 0.27; 'message- id:@mail.gmail.com': 0.27; 'run': 0.28; 'url:mailman': 0.29; 'words': 0.29; "i'm": 0.29; 'normally': 0.30; 'code': 0.31; '(and': 0.32; 'url:python': 0.32; 'url:listinfo': 0.32; 'another': 0.33; 'received:google.com': 0.34; 'christian': 0.34; 'fail': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'test': 0.36; 'should': 0.36; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'header:Received:5': 0.40; 'url:mail': 0.40; 'more': 0.63; 'show': 0.63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=466fbOwOs5Gb0gmW/0rx3hA7DUXTmURiJvr2Jw+U968=; b=rZ67dfYbfjgcqW4b0r0bKsd6KTWj9AJjiEI6a/bAWLd2zhbRs8w5g24vpHtg7Kblp5 LutyHxsmEGEyN/wXBxhrrRsOBFOaE8FlE95hOU2qi9orbTOlmCvyNPUbVngs9PYmXqzD mVtX7vMIhQMnvKtWMxNa/TPDvRHgVSf+AyuXL1hc9wUfw8p3ss6va7b2inM5QG+TJ3Z+ ukfVqMGKa02HQllQnRXEFhOgEO/69iSp5ZsAQNf/nYQoDIAxZWfAd61HrbcSy45XPUK3 BYAQRIol+TdlgVdab7PRoRV1A3aba/K01jK13rKZnatDrAfOtTtU9GphNSksrvyeN9CR 7F7Q== MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 16 Jul 2012 15:37:38 +0100 Subject: Re: assertraises behaviour From: andrea crotti To: Christian Heimes Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342449461 news.xs4all.nl 6937 [2001:888:2000:d::a6]:53854 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25420 2012/7/16 Christian Heimes : > > The OSError isn't catched as the code never reaches the line with "raise > OSError". In other words "raise OSError" is never executed as the > exception raised by "assert False" stops the context manager. > > You should avoid testing more than one line of code in a with > self.assertRaises() block. > > Christian > > -- > http://mail.python.org/mailman/listinfo/python-list Ok now it's more clear, and normally I only test one thing in the block. But I find this quite counter-intuitive, because in the block I want to be able to run something that raises the exception I catch (and which I'm aware of), but if another exception is raised it *should* show it and fail in my opinion..