A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-June/054393.html below:

[Python-Dev] Explicitly declaring expected exceptions for ablock

[Python-Dev] Explicitly declaring expected exceptions for ablock [Python-Dev] Explicitly declaring expected exceptions for ablockMichael Chermside mcherm at mcherm.com
Tue Jun 21 13:12:23 CEST 2005
Dmitry Dvoinikov writes:
> The reason for that being self-tests with lots and lots of
> little code snippets like this:
>
> try:
>     c().foo()
> except TypeError:
>     pass

Paul Du Boise already responded explaining that PEP 343 probably handles
the task you want. I just wanted to mention that you may need to
reconsider the task. The above snippet is almost certainly incorrect.
I suspect that you wanted either:

   try:
       c().foo()
       fail('Should have raised TypeError')
   except TypeError:
       pass  # expected

or perhaps this:

    try:
        c().foo()
    except TypeError:
        fail('Should not have raised TypeError')

There ARE situations when you want to allow an exception (but not
necessarily expect it) and do nothing when it occurs, but I don't
find them all that common, and I certainly don't find them arising
in unit tests.

-- Michael Chermside

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4