Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52209
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-08-08 09:20 -0700 |
| References | <215331fa-379f-4251-b722-44555349fbb5@googlegroups.com> <mailman.341.1375949083.1251.python-list@python.org> |
| Message-ID | <292722f2-56a7-4a9d-a3ad-e65b44cac834@googlegroups.com> (permalink) |
| Subject | Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" |
| From | adam.preble@gmail.com |
On Thursday, August 8, 2013 3:04:30 AM UTC-5, Terry Reedy wrote: > I cannot help but note that this is *more* typing. But anyhow, something It wasn't so much about the typing so much as having "test" in front of everything. It's a problem particular to me since I'm writing code that, well, runs experiments. So the word "test" is already all over the place. I would even prefer if I could do away with assuming everything starting with "test" is a unittest, but I didn't think I could; it looks like Peter Otten got me in the right direction. > like this might work. > > def test(f): > > f.__class__.__dict__['test_'+f.__name__] > > > > might work. Or maybe for the body just > > setattr(f.__class__, 'test_'+f.__name__) > Just for giggles I can mess around with those exact lines, but I did get spanked trying to do something similar. I couldn't reference __class__ for some reason (Python 2.7 problem?).
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is it possible to make a unittest decorator to rename a method from "x" to "testx?" adam.preble@gmail.com - 2013-08-07 23:32 -0700
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" Terry Reedy <tjreedy@udel.edu> - 2013-08-08 04:04 -0400
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" adam.preble@gmail.com - 2013-08-08 09:20 -0700
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" Terry Reedy <tjreedy@udel.edu> - 2013-08-08 15:28 -0400
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" Peter Otten <__peter__@web.de> - 2013-08-08 10:32 +0200
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" Peter Otten <__peter__@web.de> - 2013-08-08 10:50 +0200
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" adam.preble@gmail.com - 2013-08-08 09:17 -0700
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" Ned Batchelder <ned@nedbatchelder.com> - 2013-08-08 13:14 -0400
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" adam.preble@gmail.com - 2013-08-08 22:07 -0700
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" Peter Otten <__peter__@web.de> - 2013-08-09 08:31 +0200
Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?" adam.preble@gmail.com - 2013-08-11 21:25 -0700
csiph-web