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


Groups > comp.lang.python > #45752

Re: subclassing from unittest

From Terry Jan Reedy <tjreedy@udel.edu>
Subject Re: subclassing from unittest
Date 2013-05-22 17:29 -0400
References <07786a18-bb9f-4434-823c-d0fe00f858b0@cl9g2000vbb.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1976.1369258172.3114.python-list@python.org> (permalink)

Show all headers | View raw


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

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