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


Groups > comp.lang.python > #45807

Re: subclassing from unittest

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: subclassing from unittest
Date 2013-05-23 08:43 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-63E1C3.08435923052013@news.panix.com> (permalink)
References <07786a18-bb9f-4434-823c-d0fe00f858b0@cl9g2000vbb.googlegroups.com> <bar07a-pca.ln1@satorlaser.homedns.org>

Show all headers | View raw


In article <bar07a-pca.ln1@satorlaser.homedns.org>,
 Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> wrote:

> if you have an intermediate class derived 
> from unittest.TestCase, that class on its own will be considered as test 
> case! If this is not what you want but you still want common 
> functionality in a baseclass, create a mixin and then derive from both 
> the mixin and unittest.TestCase for the actual test cases.

Or, try another trick I picked up somewhere.  When you're done defining 
your test classes, delete the intermediate base class, so it won't be 
autodiscovered!

class MyBaseTestClass(unittest.TestCase):
   pass

class MyRealTest1(MyBaseTestClass):
   pass

class MyRealTest2(MyBaseTestCalss):
   pass

del MyBaseTestClass

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


Thread

subclassing from unittest Charles Smith <cts.private.yahoo@gmail.com> - 2013-05-22 08:32 -0700
  Re: subclassing from unittest Charles Smith <cts.private.yahoo@gmail.com> - 2013-05-22 08:47 -0700
  Re: subclassing from unittest Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-22 17:29 -0400
  Re: subclassing from unittest Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-05-23 08:58 +0200
    Re: subclassing from unittest Roy Smith <roy@panix.com> - 2013-05-23 08:43 -0400
    Re: subclassing from unittest Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-23 15:42 -0400

csiph-web