Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: Python unittest2.SkipTest and general suggestion Date: Sun, 21 Feb 2016 21:27:31 +0530 Lines: 98 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de mY49+9bHTDXm6VwK1hfeWgQusYMWaFWDNCqWVkPw/paA== Return-Path: 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; '"""': 0.05; 'error:': 0.05; 'importerror:': 0.05; '__name__': 0.07; 'main()': 0.07; 'unittest': 0.07; 'func': 0.09; 'example:': 0.10; 'skip:= 70': 0.10; 'python': 0.10; 'exception': 0.13; 'def': 0.13; "'__main__':": 0.16; '@classmethod': 0.16; 'main():': 0.16; 'offset,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:l 30': 0.18; 'try:': 0.18; 'team,': 0.18; 'tests': 0.18; 'to:name:python-list@python.org': 0.20; 'keyerror:': 0.22; 'import': 0.24; '(most': 0.24; 'example': 0.26; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; '2.6': 0.27; 'executing': 0.27; 'function': 0.28; 'skip:u 20': 0.28; 'skip:( 20': 0.28; 'initial': 0.28; 'subject:skip:u 10': 0.29; 'code:': 0.29; 'raise': 0.29; 'reporting': 0.29; 'code': 0.30; 'skip:[ 10': 0.31; 'skip:s 30': 0.31; 'getting': 0.33; 'run': 0.33; 'class': 0.33; 'traceback': 0.33; 'file': 0.34; 'except': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'tool': 0.36; 'received:209.85': 0.36; 'guidance': 0.36; 'to:addr:python-list': 0.36; 'display': 0.37; 'skip:s 50': 0.37; 'suggestion': 0.37; 'received:209': 0.38; 'test': 0.39; 'data': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'provide': 0.61; 'integrity': 0.76; 'succeeds': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=U8q6FkF/GWR2m37uwU3d29pD+e07D2sZV5c7xsBOFnI=; b=Z7ei1hX8cQR/0hTDP4p2ugNCjdP/jYixuUGMzHuu5+Ot5bqXfjTiqVmootuvUBNYMF kYo4MeP8Dy1BH+N7844eoEGaWCaJtMnOj43TETBKZw6a6yFe6H459PTVfVKekNg+huua wqkpgcKl6m5JHcAXpbfwon9JA5/mcPnATVhfgL6D9ym/uWghxv/iFbTzNdTD/SfHQco3 vBop+45IlCj3+F9pZhClD/VIXHGaCn23+Jp+J5cvSpXaEmMgaEWYfC9rz/HR+KQ0CrWk iJ2iihlRiOfTuFsO7gISjJdydk4tUWpq3ALY3y6L6gENhu5uZ73Ru+OQ3+r7r8tyDWM7 19Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=U8q6FkF/GWR2m37uwU3d29pD+e07D2sZV5c7xsBOFnI=; b=QMHSbHaKaZxc4DTXw+4i+FfS5T6ZIlPJjLDss77hEyKnoPPlz5lYIQV/aR/7QnaInF Xtq3cCU9TXr2esrZCXWWRatYxkxy2uNzASepLtLYknWNJ47/OMAPyjLdM58hN9t3PcEn mh58EYG3Rp8dPc6dH87je1bMHw8sAPt7khOjzNx0pP8AZOduC9gzhjTfEOgAGhUuxIXE YR0g1WggWefETzVWcY37GbI9arPVq1TSTESxhF0HYbMmcqjPyMyd4h42TFR7fPNqyA1W dXg96ngav8cpXGDnGTFVPx4U1qpmrXvySU7RaCobWFK6GHY7UoXwSUUQdzRJ2GPT2CH9 KBhQ== X-Gm-Message-State: AG10YOR59Pw1YrmnbKweFhRO13m9Pmpak9vgNHurYhLbqqD7MNFyg1ycL+uF6efSFYv+VdvjYg6bK3klmvTRng== X-Received: by 10.112.159.233 with SMTP id xf9mr8619512lbb.21.1456070251644; Sun, 21 Feb 2016 07:57:31 -0800 (PST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103300 Hello team, Please provide your guidance on how to proceed with the below test , Iam on python 2.6 and Linux. I have a linitation to use python 2.6 and unittest2 try: import unittest2 as unittest except ImportError: import unittest class isiCorruptTest(unittest.TestCase): corrupt_baddr = {} report= "" @classmethod def setUpClass(cls): cls.corruptSetup() @classmethod def corruptSetup(cls): """ Initial setup before unittest run """ logging.info("SETUP.....Started !!!") try: logging.info("Capturing data as part of prechecks for test_xx") capture_data() except Exception as e: logging.error(e) sys.exit("Corruption injection failed...Exiting !!!") try: corrupt.run_scan() except Exception as e: logging.error(e) raise unittest.SkipTest("Failure running Integrity Scan ") try: cls.report = corrupt.run_report() except Exception as e: logging.error(e) raise unittest.SkipTest("Failure running Reporting Tool ") #sys.exit(1) logging.info("SETUP.....Done !!!") def test_04_inode(self): """ test04: """ logging.info("### Executing test04: ###") self.assertTrue(corrupt.run_query(self.__class__.report, self.corrupt_baddr['test04'])) def main(): """ ---MAIN--- """ # both function are not shown in this code functions = [create_logdir, create_dataset ] for func in functions: try: func() except Exception as e: logging.error(e) return False unittest.main() if __name__ == '__main__': main() I have the below problems while running this code: 1. unittest.SkipTest does not the display the exception message that is caught. Example : The function corrupt.run_scan() returns none and False for failures 3. how do I the ensure that test_04 is run only it setUpClass succeeds ? Example: Iam getting this error message for each tests on the console. ====================================================================== ERROR: test_04_inode (__main__.isiCorruptTest) test04: inode offset, size corruption ---------------------------------------------------------------------- Traceback (most recent call last): File "c_t1.py", line 251, in test_04_inode_offset_size_corruption self.corrupt_baddr['test04'])) KeyError: 'test04' 3. Any other suggestion welcome Regards, Ganesh