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


Groups > comp.lang.python > #103307

Re: Python unittest2.SkipTest and general suggestion

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: Python unittest2.SkipTest and general suggestion
Date 2016-02-22 04:03 +1100
Message-ID <mailman.15.1456074199.20994.python-list@python.org> (permalink)
References <CACT3xuUvzKN=WoE-+E2a+stOmDmmBTdp90ZOxxLydkyH2XuGhA@mail.gmail.com>

Show all headers | View raw


Ganesh Pal <ganesh1pal@gmail.com> writes:

> 1. unittest.SkipTest does not the display the exception message that
> is caught.

You are already supplying a custom message to ‘self.skipTest’::

    except Exception as exc:
        logging.error(exc)
        raise unittest.SkipTest("Failure running Integrity Scan ")

So you can change that message by including the text representation of
the exception object::

    except Exception as exc:
        logging.error(exc)
        raise unittest.SkipTest(
                "Failure running Integrity Scan: {exc}".format(exc=exc))

> 3. how do I the ensure that test_04 is run only it setUpClass succeeds
> ?

If setupClass fails, why would you want to continue? Handle the error
inside the code for ‘setUpClass’.

If that's not obvious, maybe you mean something different by “only if
setUpClass succeeds”.

> 3.  Any other suggestion welcome

Please try hard to migrate to a currently-supported Python version. The
Python Software Foundation no longer supports Python 2.6, and that
translates into a justifiable desire in the Python community to also
stop supporting it.

-- 
 \     “We live in capitalism. Its power seems inescapable. So did the |
  `\   divine right of kings.” —Ursula K. LeGuin, National Book Awards |
_o__)                                    acceptance speech, 2014-11-19 |
Ben Finney

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


Thread

Re: Python unittest2.SkipTest and general suggestion Ben Finney <ben+python@benfinney.id.au> - 2016-02-22 04:03 +1100

csiph-web