subclassing from unittest

Charles Smith cts.private.yahoo at gmail.com
Wed May 22 11:47:41 EDT 2013


On 22 Mai, 17:32, Charles Smith <cts.private.ya... at gmail.com> wrote:
> Hi,
>
> I'd like to subclass from unittest.TestCase.  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:
>
>   class StdTestCase (unittest.TestCase):
>       blahblah
>
> 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.
>
> I suspect that the answer is in the prefix printed out by the test.  I
> have diffed both the long output (tests works, on the left) and the
> short output (null test, on the right):
>
> test
> (TC_02.TestCase_F_0000_ULLA05_xxxxxxxx_AM_Tx) ...                  <
> test suite has  <unittest.TestSuite tests=[<unittest.TestSuite
> tests=[]>,       test suite has  <unittest.TestSuite
> tests=[<unittest.TestSuite tests=[]>,
>
> >    <unittest.TestSuite tests=[]>,
>
>  <unittest.TestSuite
> tests=[<TC_02.TestCase_F_0000_ULLA05_xxxxxxxx_AM
> <unittest.TestSuite tests=[<TC_02.TestCase_F_0000_ULLA05_xxxxxxxx_AM
>  <unittest.TestSuite
> tests=[<TC_02.TestCase_F_0001_ULLA10_xxxxxxxx_AM
> <unittest.TestSuite tests=[<TC_02.TestCase_F_0001_ULLA10_xxxxxxxx_AM
>  <unittest.TestSuite
> tests=[<TC_02.TestCase_F_0002_ULLA20_xxxxxxxx_AM
> <unittest.TestSuite tests=[<TC_02.TestCase_F_0002_ULLA20_xxxxxxxx_AM
>  <unittest.TestSuite
> tests=[<TC_02.TestCase_F_0003_ULLA05_xxxxxxxx_UM
> <unittest.TestSuite tests=[<TC_02.TestCase_F_0003_ULLA05_xxxxxxxx_UM
>  <unittest.TestSuite
> tests=[<TC_02.TestCase_F_0005_ULLA10_xxxxxxxx_UM
> <unittest.TestSuite tests=[<TC_02.TestCase_F_0005_ULLA10_xxxxxxxx_UM
>  <unittest.TestSuite
> tests=[<TC_02.TestCase_F_0006_ULLA20_xxxxxxxx_UM   |
> <unittest.TestSuite tests=[<TC_02.TestCase_F_0006_ULLA20_xxxxxxxx_UM
>  <unittest.TestSuite
> tests=[]>]>                                        <
>
> >   ---------->  test_api_socket:the address specified is:  127.0.0.1
>
> ----------------------------------------------------------------------
>
> >   Ran 0 tests in 0.000s
>
> >   OK
>
> I see an empty test somehow gets sorted to the beginning of the list.
> How could that be a result of whether the first letter of the class is
> capitalized or not?
>
> Thanks in advance...
> cts
>
> --------------------------------------------------------http://www.creative-telcom-solutions.de


Unfortunately, the side-by-side diff didn't come out so well  ...

---------------------------------------
http://www.creative-telcom-solutions.de



More information about the Python-list mailing list