Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107114
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to parameterize unittests |
| Date | Sat, 16 Apr 2016 22:37:52 +0200 |
| Lines | 47 |
| Message-ID | <mailman.64.1460839145.6324.python-list@python.org> (permalink) |
| References | <570FA466.20003@rece.vub.ac.be> <mailman.106.1460642951.15650.python-list@python.org> <570fb1a3$0$1609$c3e8da3$5496439d@news.astraweb.com> <57108FAC.3020105@rece.vub.ac.be> <CAPTjJmreV+Ed722t7mUUC62L2u8gT-CE5K9ASGon1PHMYFdmTQ@mail.gmail.com> <5710A442.8000906@rece.vub.ac.be> <mailman.5.1460708428.6324.python-list@python.org> <5710affd$0$22140$c3e8da3$5496439d@news.astraweb.com> <5710D3DA.6030005@rece.vub.ac.be> <5710E30B.6050304@rece.vub.ac.be> <mailman.22.1460724628.6324.python-list@python.org> <57111b0b$0$1606$c3e8da3$5496439d@news.astraweb.com> <5712A2A0.7080606@rece.vub.ac.be> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de Zs2JuOgTQStLHOVAKFV6dgBOFcETGGMFC0H0GV/QNZ3Q== |
| Return-Path | <antoon.pardon@rece.vub.ac.be> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'static': 0.03; 'keys,': 0.07; 'locale': 0.07; 'subject:How': 0.09; 'subclass': 0.09; 'subclasses': 0.09; 'def': 0.13; 'argument': 0.15; '2016': 0.16; 'iterators': 0.16; 'received:adsl-dyn.isp.belgacom.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subclasses,': 0.16; 'subclassing': 0.16; 'wrote:': 0.16; 'duplicate': 0.18; 'tree': 0.18; 'tests': 0.18; "aren't": 0.22; 'keys': 0.22; 'seems': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'fri,': 0.27; 'order.': 0.27; 'methods.': 0.29; 'received:192.168.1.3': 0.29; 'classes': 0.30; 'received:be': 0.30; "can't": 0.32; 'point': 0.33; 'class': 0.33; 'steven': 0.33; 'similar': 0.33; 'case,': 0.34; 'changing': 0.34; 'done': 0.35; 'instance': 0.35; 'according': 0.36; 'but': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'starting': 0.37; 'things': 0.38; 'presence': 0.38; 'means': 0.39; 'test': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'different': 0.63; 'realise': 0.66; "they're": 0.66; "d'aprano:": 0.84; 'pardon': 0.84; 'received:195.238': 0.84; 'schreef': 0.84; 'sort.': 0.84 |
| X-Belgacom-Dynamic | yes |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | A2CVAQAEohJX/w1W8lENT8Eghg4CgWARAQEBAQEBAYVOAQEEeBELGAkWDwkDAgECAUUTCAKxLI1QhE4BAQgCHoYhhEuFC4UKAQSYDoFVhxaFI48Rjys2hBaKNQEBAQ |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 |
| In-Reply-To | <57111b0b$0$1606$c3e8da3$5496439d@news.astraweb.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <5712A2A0.7080606@rece.vub.ac.be> |
| X-Mailman-Original-References | <570FA466.20003@rece.vub.ac.be> <mailman.106.1460642951.15650.python-list@python.org> <570fb1a3$0$1609$c3e8da3$5496439d@news.astraweb.com> <57108FAC.3020105@rece.vub.ac.be> <CAPTjJmreV+Ed722t7mUUC62L2u8gT-CE5K9ASGon1PHMYFdmTQ@mail.gmail.com> <5710A442.8000906@rece.vub.ac.be> <mailman.5.1460708428.6324.python-list@python.org> <5710affd$0$22140$c3e8da3$5496439d@news.astraweb.com> <5710D3DA.6030005@rece.vub.ac.be> <5710E30B.6050304@rece.vub.ac.be> <mailman.22.1460724628.6324.python-list@python.org> <57111b0b$0$1606$c3e8da3$5496439d@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:107114 |
Show key headers only | View raw
Op 15-04-16 om 18:47 schreef Steven D'Aprano: > On Fri, 15 Apr 2016 10:48 pm, Antoon Pardon wrote: > >> Starting from this: >> >> class Test_AVLTree(unittest.TestCase): >> >> def test_empty_tree_is_false(self): >> instance = avltree() >> self.assertFalse(instance) >> >> Changing it into this: >> >> def MakeAVLTest(avltree): >> class Test_AVLTree(unittest.TestCase): >> >> def test_empty_tree_is_false(self): >> instance = avltree() >> self.assertFalse(instance) >> >> return Test_AVLTree >> >> AVLTest = MakeAVLTest(avltree) >> MyTreeTest = MakeAVLTest(mytree) >> >> Seems to work > > Right up to the moment that you realise that you need different tests for a > subclass, and now you can't using subclassing because they aren't > subclasses, they're completely independent classes that happen to duplicate > the same methods. > > If the tests for your AVL tree and it's subclasses are *identical*, then > what's the point of the subclasses? The subclass has a key-function as a static method similar to the key argument for sort. This way I can have a tree with strings as keys, but with the keys sorted according to the locale with the locale.strxfrm function. This means the only tests that need changing are the tests that test for iterators to deliver the items in sorted order. But that can be done by letting the test check for the presence of the keyfunction and in that case, use if to check if things are in order. -- Antoon
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to parameterize unittests Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-14 16:08 +0200
Re: How to parameterize unittests Steven D'Aprano <steve@pearwood.info> - 2016-04-15 01:05 +1000
Re: How to parameterize unittests Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-15 08:52 +0200
Re: How to parameterize unittests Chris Angelico <rosuav@gmail.com> - 2016-04-15 17:42 +1000
Re: How to parameterize unittests Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-15 10:20 +0200
Re: How to parameterize unittests Steven D'Aprano <steve@pearwood.info> - 2016-04-15 19:10 +1000
Re: How to parameterize unittests Michael Selik <michael.selik@gmail.com> - 2016-04-15 10:05 +0000
Re: How to parameterize unittests Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-15 13:43 +0200
Re: How to parameterize unittests Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-15 14:48 +0200
Re: How to parameterize unittests Steven D'Aprano <steve@pearwood.info> - 2016-04-16 02:47 +1000
Re: How to parameterize unittests Chris Angelico <rosuav@gmail.com> - 2016-04-16 03:51 +1000
Re: How to parameterize unittests Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-16 22:37 +0200
Re: How to parameterize unittests Serhiy Storchaka <storchaka@gmail.com> - 2016-04-15 11:24 +0300
Re: How to parameterize unittests Chris Angelico <rosuav@gmail.com> - 2016-04-15 18:28 +1000
Re: How to parameterize unittests Serhiy Storchaka <storchaka@gmail.com> - 2016-04-15 11:31 +0300
Re: How to parameterize unittests Ben Finney <ben+python@benfinney.id.au> - 2016-04-15 18:35 +1000
csiph-web