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


Groups > comp.lang.python > #103312 > unrolled thread

Re: Python unittest2.SkipTest and general suggestion

Started byGanesh Pal <ganesh1pal@gmail.com>
First post2016-02-21 23:33 +0530
Last post2016-02-21 23:33 +0530
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python unittest2.SkipTest and general suggestion Ganesh Pal <ganesh1pal@gmail.com> - 2016-02-21 23:33 +0530

#103312 — Re: Python unittest2.SkipTest and general suggestion

FromGanesh Pal <ganesh1pal@gmail.com>
Date2016-02-21 23:33 +0530
SubjectRe: Python unittest2.SkipTest and general suggestion
Message-ID<mailman.19.1456077794.20994.python-list@python.org>
On Sun, Feb 21, 2016 at 10:33 PM, Ben Finney <ben+python@benfinney.id.au> wrote:

> 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))
>


Thank you for the pointers , but I modified my code to use raise
instead of exception , just wondering how will I display the message
with the below code ,

Sample code :

import os
try:
    import unittest2 as unittest
except ImportError:
    import unittest

class MyTests(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        #x = False
        x = None
        if not x:
            raise unittest.SkipTest(
                "class setup failed")

    def test_one(self):
        print "test_one"

    def test_two(self):
        print "test_two"

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

output:

gpal-3c6dc81-1# python c_4.py
s
----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK (skipped=1)

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web