Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107028
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: How to parameterize unittests |
| Date | 2016-04-15 17:42 +1000 |
| Message-ID | <mailman.4.1460706139.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> |
On Fri, Apr 15, 2016 at 4:52 PM, Antoon Pardon <antoon.pardon@rece.vub.ac.be> wrote: > Op 14-04-16 om 17:05 schreef Steven D'Aprano: >> On Fri, 15 Apr 2016 12:08 am, Antoon Pardon wrote: >> >>> I have a unittest for my avltree module. >>> >>> Now I want this unittest to also run on a subclass of avltree. >>> How can I organise this, so that I can largely reuse the >>> original TestCase? >> >> class Test_AVLTree(unittest.TestCase): >> tree = avltree >> >> def test_empty_tree_is_false(self): >> instance = self.tree() >> self.assertFalse(instance) >> >> >> class Test_MySubclassTree(Test_AVLTree): >> tree = My_Subclass_Tree > > I see, that's going to be a lot of cut & pastes. > Thanks. Not really; the first class has all the tests, and the second one is literally just those two lines. It overrides 'tree' (accessed inside methods as 'self.tree'), and since all the tests are written to instantiate self.tree, they are effectively parameterized. ChrisA
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