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


Groups > comp.lang.python > #103312

Re: Python unittest2.SkipTest and general suggestion

Path csiph.com!2.us.feeder.erje.net!feeder.erje.net!2.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From Ganesh Pal <ganesh1pal@gmail.com>
Newsgroups comp.lang.python
Subject Re: Python unittest2.SkipTest and general suggestion
Date Sun, 21 Feb 2016 23:33:06 +0530
Lines 59
Message-ID <mailman.19.1456077794.20994.python-list@python.org> (permalink)
References <CACT3xuUvzKN=WoE-+E2a+stOmDmmBTdp90ZOxxLydkyH2XuGhA@mail.gmail.com> <85d1rq0zed.fsf@benfinney.id.au>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de bUdYg1w2aAm0XhlC+0yP6gWS3jQ3D37G/AgCC6s7DNRA==
Return-Path <ganesh1pal@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'importerror:': 0.05; 'modified': 0.05; '"__main__":': 0.07; '21,': 0.07; '__name__': 0.07; 'unittest': 0.07; 'cc:addr:python- list': 0.09; 'pointers': 0.09; 'python': 0.10; 'exception': 0.13; 'def': 0.13; '2016': 0.16; '@classmethod': 0.16; 'failed")': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'supplying': 0.16; 'wrote:': 0.16; 'skip:{ 20': 0.18; 'try:': 0.18; 'tests': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'feb': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'wondering': 0.25; 'message-id:@mail.gmail.com': 0.27; 'skip:u 20': 0.28; 'subject:skip:u 10': 0.29; 'raise': 0.29; 'print': 0.30; 'code': 0.30; 'class': 0.33; 'except': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'text': 0.35; 'false': 0.35; 'but': 0.36; 'instead': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'display': 0.37; 'received:209': 0.38; 'thank': 0.38; 'skip:u 10': 0.61; 'sample': 0.63; 'integrity': 0.76
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=SEiBa4ET9EwFHM78UOJurg89OyDAWE8grjcb8bKR3yQ=; b=uTgeOkaSosCB5fD1HGBaIVNVNVs1VpzvrOHtA8s1WGqV87sk2pVYtIgiM8SIpsqH3C lrLXkLMjfVt++6lR0mnIPVPCGxc4AfCQ1goawi2l/V8HXj0nuH1u+RSVBm04jRiYhq4j tecchi/ZwcSdxGsO5iNUSNIcY/Jbj0PguHIKM12g99a/OIEMFwN6gS+fJc7QKZXUX3C4 adl5TZ3SozUT/aPv/tQ4IWs1Tp+Bm6sMsR6WW+bwghvZf95knjfoayX5Uh0bL/V1xvL4 xpjc39iwJHV6vvQnOK8g1K5+lITIXCIRvm+eZWFUJo2BLnLwUb7z/917p0YC6W6lTDfU Syvg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=SEiBa4ET9EwFHM78UOJurg89OyDAWE8grjcb8bKR3yQ=; b=k7kdlNQBfZHx2w8LEP/NAwYWwYt8DeZEC9IoI5g3u2hI8xlWrbRP1q5DVSIAmDkn4k eLsqjiSgoEhhWyuyBy8eE5GeQViOVSxbG5PsC6roqmM1oxOIzMXKKPfO8mDsYy4NYnmO j9SEyidMc386gu5d8dna88ZruBvFiYOJ2qumqYqsOpfq1HEZkSCcRCvoNMaddulUA+AS Mz8Yow6j6/zcDiHZeODh9ocWOssu3uB83nJL5v7TDEk34/wom8XoJ0/HchlrUewe55T1 qnfGBm6bqAtjme7r/8IfmbqMXE3rTRvcgqN4jpGHkVBgls+6X4/JyrhzIUYYGECjbcJJ DZgw==
X-Gm-Message-State AG10YOS7lMqebgaoa4jTbO2DykXCLAcolhf0TVqmPMsz09ZJAX5W4EkTbDpaczrni186YCJBgI1FfM1OwVlWfA==
X-Received by 10.112.159.233 with SMTP id xf9mr8745488lbb.21.1456077786762; Sun, 21 Feb 2016 10:03:06 -0800 (PST)
In-Reply-To <85d1rq0zed.fsf@benfinney.id.au>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:103312

Show key headers only | View raw


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)

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


Thread

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

csiph-web