Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'modify': 0.07; 'tests.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'unittest': 0.09; 'url:faqs': 0.09; 'jan': 0.12; 'suggest': 0.14; '11:32': 0.16; 'added.': 0.16; 'charles': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subclass': 0.16; 'subclasses': 0.16; 'url:catb': 0.16; 'wrote:': 0.18; 'import': 0.22; 'tests': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; '(or': 0.24; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'rest': 0.29; 'am,': 0.29; 'wonder': 0.29; 'skip:( 20': 0.30; 'prints': 0.31; 'anyone': 0.31; 'class': 0.32; 'run': 0.32; "i'd": 0.34; 'subject:from': 0.34; 'skip:u 20': 0.35; 'something': 0.35; 'done.': 0.35; 'test': 0.35; 'but': 0.35; 'version': 0.36; 'url:org': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'explain': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'received:173': 0.61; 'first': 0.61; 'on...': 0.68; 'smith': 0.68; 'completes': 0.84; 'observed': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Jan Reedy Subject: Re: subclassing from unittest Date: Wed, 22 May 2013 17:29:23 -0400 References: <07786a18-bb9f-4434-823c-d0fe00f858b0@cl9g2000vbb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <07786a18-bb9f-4434-823c-d0fe00f858b0@cl9g2000vbb.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369258172 news.xs4all.nl 15902 [2001:888:2000:d::a6]:52262 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45752 On 5/22/2013 11:32 AM, Charles Smith wrote: Have you red this? I will suggest some specifics. http://www.catb.org/esr/faqs/smart-questions.html > I'd like to subclass from unittest.TestCase. What version of Python. > I observed something interesting and wonder if anyone can explain what's going on... some > subclasses create null tests. > > I can create this subclass and the test works: What does 'works' mean? > class StdTestCase (unittest.TestCase): > blahblah I bet that this (and the rest of your 'code' is not what you actually ran. Unless blahblah is bound (to what?), this fails with NameError. Give us what you ran so we can run it too, and modify it. > and I can create this subsubclass and the test works: > > class aaaTestCase (StdTestCase): > moreblahblah > > but if I create this subsubclass (or any where the first letter is > capital): > > class AaaTestCase (StdTestCase): > differentblahblah > > the test completes immediately without any work being done. What does this mean? I see no difference with the following import unittest class StdTestCase (unittest.TestCase): pass class lowerSub(StdTestCase): pass class UpperSub(StdTestCase): pass unittest.main(verbosity=2, exit=False) # prints (3.3) ---------------------------------------------------------------------- Ran 0 tests in 0.000s OK Same as before the subclasses were added. -- Terry Jan Reedy