Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45780
| From | Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: subclassing from unittest |
| Date | 2013-05-23 08:58 +0200 |
| Message-ID | <bar07a-pca.ln1@satorlaser.homedns.org> (permalink) |
| References | <07786a18-bb9f-4434-823c-d0fe00f858b0@cl9g2000vbb.googlegroups.com> |
Am 22.05.2013 17:32, schrieb Charles Smith: > 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 perhaps guess what's going on, though Terry is right: Your question isn't very helpful and informative. > 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. Well, per PEP 8, classes use CamelCaps, so your naming might break automatic test discovery. Then, there might be another thing that could cause this, and that is that if you have an intermediate class derived from unittest.TestCase, that class on its own will be considered as test case! If this is not what you want but you still want common functionality in a baseclass, create a mixin and then derive from both the mixin and unittest.TestCase for the actual test cases. Good luck! Uli
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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