Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: Re: Fwd: python unit test framework sample code Date: Mon, 11 Jan 2016 15:35:51 +0530 Lines: 117 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de +EYqv8AnNHrCy8VxP9hEaATsiWNDi3g4PMaYWhrElUqA== 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; '"""': 0.05; 'overflow': 0.07; 'run,': 0.07; 'subject:code': 0.07; 'subject:test': 0.07; 'unittest': 0.07; 'python': 0.10; 'jan': 0.11; 'stack': 0.13; 'def': 0.13; 'subject:python': 0.14; '>>>': 0.15; 'skip:f 30': 0.15; 'thu,': 0.15; '(possible': 0.16; '2016': 0.16; '@classmethod': 0.16; 'email addr:udel.edu>': 0.16; 'email name:<tjreedy': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'subject:sample': 0.16; 'unittest,': 0.16; 'unittest2.': 0.16; 'wrote:': 0.16; 'refers': 0.18; 'skip:l 30': 0.18; 'version.': 0.18; '>': 0.18; 'email addr:gmail.com>': 0.18; 'tests': 0.18; '>>>': 0.20; 'assuming': 0.22; 'trying': 0.22; 'header:In-Reply-To:1': 0.24; 'module': 0.25; '----------': 0.25; 'example': 0.26; 'skip:t 40': 0.27; 'message- id:@mail.gmail.com': 0.27; '2.6': 0.27; 'initial': 0.28; 'looks': 0.29; '(perhaps': 0.29; 'code': 0.30; 'class.': 0.30; 'error.': 0.31; 'date:': 0.31; 'skip:s 30': 0.31; 'skip:_ 10': 0.32; 'older': 0.32; 'run': 0.33; 'changed': 0.33; 'class': 0.33; "skip:' 20": 0.34; 'running': 0.34; 'received:google.com': 0.35; 'instance': 0.35; 'newer': 0.35; 'skip:s 60': 0.35; 'subject:': 0.35; 'unit': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'should': 0.36; 'instead': 0.36; 'received:209.85': 0.36; 'framework': 0.36; 'guidance': 0.36; 'totally': 0.36; 'to:addr:python-list': 0.36; 'forwarded': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'method': 0.37; 'setting': 0.37; 'received:209': 0.38; 'test': 0.39; 'sure': 0.39; "didn't": 0.39; 'easily': 0.39; 'from:': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'skip:u 10': 0.61; 'body': 0.61; 'provide': 0.61; 'real': 0.62; 'here.': 0.62; 'more': 0.63; 'sample': 0.63; 'reply': 0.68; 'url:info': 0.71; 'upgrading': 0.72 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 :content-type; bh=1TedhfpMr8ExSVgwSfvQOd+bG5Umw9erfBaj0vkPlJI=; b=lLK2OrjUhDG6+sSCElFffT/1IuLCXNH7RLOBPXwhKy1mSM/45L3LYXemQViOXLr5/c yH+SCnIJ8EJp/j60Yj193CBzp2tv6fvtcJGQOaP7589z/s4CyVKR8aGrBb/3CeTDGfOa 3z4w9GFosiebYo3eI/8vksT5egVvDaaFveccMuKeMRIMibgZZxg5qmaoSKZJv1ygxQ6P rLj02eBnWOGC9pEIzNqpvwsmUjinEqHlwOiuLVkjIwU829Fv/8ncBc8LFBDwSCemOtIh 5hO0/iCdZ/nvGSmXokmQOYLngb8j6hokelhMlmbQadvQXs9Pgh8FClYHjebdMe3H171Z cDwg== X-Received: by 10.25.19.151 with SMTP id 23mr47137095lft.40.1452506751483; Mon, 11 Jan 2016 02:05:51 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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:101471 Totally stuck with this On Jan 10, 2016 7:11 PM, "Ganesh Pal" wrote: > Apologies, looks like I did a reply instead of reply-all. So > forwarding this email , please provide guidance on the same > > ---------- Forwarded message ---------- > From: Ganesh Pal > Date: Thu, Jan 7, 2016 at 12:26 PM > Subject: Re: python unit test framework sample code > To: Terry Reedy > > > Unless you have a large program already in 2.6 and are just adding tests > > (perhaps so you can more easily upgrade someday), consider upgrading to a > > newer version. > > Sure , but for now Iam limited to use 2.6 , hence I cant upgrade need > to work with 2.6 > > >> > >> class FileSystemTest(unittest2.TestCase): > >> block_address = {} > >> report = "" > >> > >> @classmethod > >> def setUpClass(cls): > >> cls.FileSystemSetup() > > > > > > This is senseless. Put the body of FileSystemSetup here. > > I didn't understand which line is senseless. I was trying to refer > this example on stack overflow > > http://stackoverflow.com/questions/5938517/not-able-call-a-local-method-from-setupclass > > > class TestSystemPromotion(unittest2.TestCase): > > @classmethod > def setUpClass(cls): > cls.setup_test_data() > > > @classmethod > def setup_test_data(cls): > ... > > def test_something(self): > ... > > > class FileSystemTest(unittest2.TestCase): > block_address = {} > report = "" > > @classmethod > def setUpClass(cls): > cls.FileSystemSetup() > > @classmethod > def FileSystemSetup(cls): > """ > Initial setup before unittest is run > """ > logging.info("SETUP.....Started !!!") > > >> def inode_corruption(self): > >> """ test_01: inode corruption """ > >> self.assertTrue(corrupt.run_query_tool(self.__class__.report, > > > > > > self.block_address['test_01'])) > > > > Assuming that unittest2 is same as unittest, test methods must be called > > test_xyz. So this is not run, hence no error. > > Sorry I have changed this from inode_corruption' to 'test_inode_corruption > > > > >> @classmethod > >> def tearDownClass(cls): > >> cls.tearDown() > > > > > > Ditto. Put real body here. > > > >> @classmethod > >> def tearDown(cls): > > > > > > > The above refers to functions you did not post. For current unittest, it > > looks likes you should be using a setUpModule (possible tearDownModule) > > functions, but I don't know if those are available in the older > unittest2. > > > we have tearDownClass and setUpClass in python 2.6 and under unittest2 > > >>> help(unittest2.TestCase.tearDownClass) > Help on method tearDownClass in module unittest2.case: > > tearDownClass(cls) method of __builtin__.type instance > Hook method for deconstructing the class fixture after running all > tests in the class. > > >>> help(unittest2.TestCase.setUpClass) > Help on method setUpClass in module unittest2.case: > > setUpClass(cls) method of __builtin__.type instance > Hook method for setting up class fixture before running tests in the > class. > > Regards, > Ganesh >