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


Groups > comp.lang.python > #30637

Re: unit testing class hierarchies

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'tests,': 0.07; 'unittest': 0.07; 'attribute.': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'testcases': 0.09; 'def': 0.10; 'skip:f 30': 0.15; '(just': 0.16; 'eckhardt': 0.16; 'invoking': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'wrote:': 0.17; 'library,': 0.17; 'cloud': 0.20; 'own.': 0.22; 'help.': 0.22; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'testcase': 0.29; 'class': 0.29; 'classes': 0.30; 'framework': 0.30; 'url:python': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'received:org': 0.36; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'test': 0.36; 'india': 0.36; 'skip:t 40': 0.37; 'ones': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'remove': 0.61; 'here': 0.65; 'decided': 0.65; 'otten': 0.84; 'received:111': 0.84; 'yusuf': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Fayaz Yusuf Khan <fayaz@dexetra.com>
Subject Re: unit testing class hierarchies
Followup-To gmane.comp.python.general
Date Tue, 02 Oct 2012 20:35:33 +0530
Organization Dexetra
References <v53rj9-5kd.ln1@satorlaser.homedns.org> <k4etu4$v1m$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host 111.92.110.232
User-Agent KNode/4.4.11
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1728.1349190398.27098.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349190398 news.xs4all.nl 6879 [2001:888:2000:d::a6]:50889
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30637

Followups directed to: gmane.comp.python.general

Show key headers only | View raw


Peter Otten wrote:

> Ulrich Eckhardt wrote:
>> The problem here is that TestBase is not a complete test case (just 
as
>> class Base is not complete), but the unittest framework will still 
try
>> to run it on its own.
How exactly are you invoking the test runner? unittest? nose? You can 
tell the test discoverer which classes you want it to run and which 
ones you don't. For the unittest library, I use my own custom 
load_tests methods:
def load_tests(loader, tests, pattern):
    testcases = [TestD1, TestD2]
    return TestSuite([loader.loadTestsFromTestCase(testcase)
                      for testcase in testcases])
http://docs.python.org/library/unittest.html#load-tests-protocol

>> One way around this is to not derive class
>> TestBase from unittest.
> 
> Another is to remove it from the global namespace with
> 
> del TestBase
Removing the class from namespace may or may not help. Consider a 
scenario where someone decided to be creative with the cls.__bases__ 
attribute.

-- 
Fayaz Yusuf Khan
Cloud architect, Dexetra SS, India
fayaz.yusuf.khan_AT_gmail_DOT_com, fayaz_AT_dexetra_DOT_com
+91-9746-830-823

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


Thread

unit testing class hierarchies Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-02 14:27 +0200
  Re: unit testing class hierarchies Demian Brecht <demianbrecht@gmail.com> - 2012-10-02 07:05 -0700
  Re: unit testing class hierarchies Thomas Bach <thbach@students.uni-mainz.de> - 2012-10-02 16:06 +0200
    Re: unit testing class hierarchies Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-02 17:24 +0200
    Re: unit testing class hierarchies Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-02 18:54 +0200
      Re: unit testing class hierarchies Peter Otten <__peter__@web.de> - 2012-10-02 19:38 +0200
      Re: unit testing class hierarchies Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-02 19:41 +0100
      Re: unit testing class hierarchies Ben Finney <ben+python@benfinney.id.au> - 2012-10-03 08:30 +1000
        Re: unit testing class hierarchies Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-03 01:20 +0000
          Re: unit testing class hierarchies Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-03 10:33 +0100
          Re: unit testing class hierarchies Terry Reedy <tjreedy@udel.edu> - 2012-10-03 16:14 -0400
  Re: unit testing class hierarchies Peter Otten <__peter__@web.de> - 2012-10-02 16:32 +0200
  Re: unit testing class hierarchies Fayaz Yusuf Khan <fayaz@dexetra.com> - 2012-10-02 20:35 +0530
  Re: unit testing class hierarchies Peter Otten <__peter__@web.de> - 2012-10-02 19:40 +0200
    Re: unit testing class hierarchies Roy Smith <roy@panix.com> - 2012-10-02 19:46 -0400

csiph-web