Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30651
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!feed.xsnews.nl!border-3.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'unittest': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.10; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'wrote:': 0.17; 'obviously': 0.18; 'tests': 0.18; 'import': 0.21; 'solutions.': 0.23; 'seems': 0.23; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.28; 'testcase': 0.29; 'class': 0.29; 'from:addr:yahoo.co.uk': 0.32; 'yours,': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'requirements': 0.33; 'clear': 0.35; 'compared': 0.35; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; "wasn't": 0.36; 'subject:: ': 0.38; 'mark': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'reply': 0.66; 'superior': 0.66; 'inefficient': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: unit testing class hierarchies |
| Date | Tue, 02 Oct 2012 19:41:11 +0100 |
| References | <v53rj9-5kd.ln1@satorlaser.homedns.org> <mailman.1725.1349186875.27098.python-list@python.org> <irirj9-sme.ln1@satorlaser.homedns.org> <k4f8q4$bgg$1@ger.gmane.org> <CAE+T62YY20kv1Yki3Noq0X_G1-RW5+kx851GmyrrZgpKpU+tsw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-78-147-18-31.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 |
| In-Reply-To | <CAE+T62YY20kv1Yki3Noq0X_G1-RW5+kx851GmyrrZgpKpU+tsw@mail.gmail.com> |
| X-Antivirus | avast! (VPS 121002-0, 02/10/2012), Outbound message |
| X-Antivirus-Status | Clean |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1740.1349203281.27098.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1349203281 news.xs4all.nl 6916 [2001:888:2000:d::a6]:59360 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:30651 |
Show key headers only | View raw
On 02/10/2012 19:06, Demian Brecht wrote:
> Am I missing something? Is there something that wasn't answered by my reply
> about using mixins?
>
> from unittest import TestCase
>
> class SharedTestMixin(object):
> def test_shared(self):
> self.assertNotEquals('foo', 'bar')
>
> class TestA(TestCase, SharedTestMixin):
> def test_a(self):
> self.assertEquals('a', 'a')
>
> class TestB(TestCase, SharedTestMixin):
> def test_b(self):
> self.assertEquals('b', 'b')
>
> $ nosetests test.py -v
> test_a (test.TestA) ... ok
> test_shared (test.TestA) ... ok
> test_b (test.TestB) ... ok
> test_shared (test.TestB) ... ok
>
> ----------------------------------------------------------------------
> Ran 4 tests in 0.001s
>
> OK
>
> This seems to be a clear answer to the problem that solves the original
> requirements without introducing error-prone, non-obvious solutions.
>
>
>
Peter Otten's response is obviously vastly superior to yours, 4 tests in
0.000s compared to your highly inefficient 4 tests in 0.001s :)
--
Cheers.
Mark Lawrence.
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