Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30637
| From | Fayaz Yusuf Khan <fayaz@dexetra.com> |
|---|---|
| Subject | Re: unit testing class hierarchies |
| Followup-To | gmane.comp.python.general |
| Date | 2012-10-02 20:35 +0530 |
| Organization | Dexetra |
| References | <v53rj9-5kd.ln1@satorlaser.homedns.org> <k4etu4$v1m$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1728.1349190398.27098.python-list@python.org> (permalink) |
Followups directed to: gmane.comp.python.general
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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