Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25415

assertraises behaviour

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'context': 0.05; '__name__': 0.07; 'bits': 0.07; 'false,': 0.07; 'unittest': 0.07; 'python': 0.09; 'oserror': 0.09; 'def': 0.10; 'to:name:python-list': 0.15; '"should': 0.16; "'__main__':": 0.16; 'fail,': 0.16; 'bit': 0.21; 'import': 0.21; 'doc': 0.22; 'received :mail-bk0-f46.google.com': 0.22; 'example': 0.23; 'raise': 0.24; 'received:209.85.214.46': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'assert': 0.29; 'behaviour': 0.29; 'class': 0.29; '(from': 0.30; 'skip:s 30': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'expected': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'skip:u 10': 0.60; '(running': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=UD3/U+c0+W6gHGBnCQEG9jrpQVIEJ9fcuDLYdWbQAGk=; b=zSNmoNdHxYA3MWU9o3iG0pFFovILcAmLXc6z4ijmd08Bs6FQQsEAaMqTfk8HGutlSD EQIK/lCWWLov7j2zpGzU67HvPTPABFt+nfLcJP5G219Wutv7y3VfboZYcPRY9T29FtZ7 aHmHFk45I7i/8wjRkZgeEaXmLedCD3Dwn3Gjsg/Cp5++7t8JSFSafT87GeeD6uTz9wkd WmgeJtRetcgAJ78YKaxVNNGdtTdrYSRKRDsm/dZl542sCN+RuLhwEzCF8qyI+pBHsGt8 QLEO1PfAQsoJ/vaRaOsA+li4bxLQh8b2T1FsNjEs9MW55U4xTmUrfbojXpeRUnP1lU5H BQtA==
MIME-Version 1.0
Date Mon, 16 Jul 2012 14:38:17 +0100
Subject assertraises behaviour
From andrea crotti <andrea.crotti.0@gmail.com>
To python-list <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2172.1342445899.4697.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1342445899 news.xs4all.nl 6947 [2001:888:2000:d::a6]:54939
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:25415

Show key headers only | View raw


I found that the behaviour of assertRaises used as a context manager a
bit surprising.

This small example doesn't fail, but the OSError exception is cathed
even if not declared..
Is this the expected behaviour (from the doc I would say it's not).
(Running on arch-linux 64 bits and Python 2.7.3, but it doesn the same
with Python 3.2.3)

import unittest

class TestWithRaises(unittest.TestCase):
    def test_ass(self):
        with self.assertRaises(AssertionError):
            assert False, "should happen"
            raise OSError("should give error")


if __name__ == '__main__':
    unittest.main()

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

assertraises behaviour andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-16 14:38 +0100

csiph-web