Python unittest2.SkipTest and general suggestion

Ben Finney ben+python at benfinney.id.au
Sun Feb 21 12:03:06 EST 2016


Ganesh Pal <ganesh1pal at 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




More information about the Python-list mailing list