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


Groups > comp.lang.python > #25420

Re: assertraises behaviour

References <CAF_E5JYANst57yOud+Ot0AbKkePruoCGPUNC5BbyBoMbgaw2_Q@mail.gmail.com> <ju16g6$8o2$1@dough.gmane.org>
Date 2012-07-16 15:37 +0100
Subject Re: assertraises behaviour
From andrea crotti <andrea.crotti.0@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2176.1342449461.4697.python-list@python.org> (permalink)

Show all headers | View raw


2012/7/16 Christian Heimes <lists@cheimes.de>:
>
> 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..

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


Thread

Re: assertraises behaviour andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-16 15:37 +0100

csiph-web