Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56617
| Date | 2013-10-10 19:44 -0400 |
|---|---|
| From | Ned Batchelder <ned@nedbatchelder.com> |
| Subject | Re: Skipping decorators in unit tests |
| References | <2490050c-61d9-4bfd-bdd5-921e2f95a44b@googlegroups.com> <20131010221238.GA27082@cskk.homeip.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.966.1381448694.18130.python-list@python.org> (permalink) |
On 10/10/13 6:12 PM, Cameron Simpson wrote: > On 10Oct2013 07:00, Gilles Lenfant <gilles.lenfant@gmail.com> wrote: >> (explaining the title) : my app has functions and methods (and >> maybe classes in the future) that are decorated by decorators >> provided by the standard library or 3rd party packages. >> >> But I need to test "undecorated" functions and methods in my unit tests, preferably without adding "special stuffs" in my target tested modules. >> >> Can someone point out good practices or dedicated tools that "remove temporarily" the decorations. >> I pasted a small example of what I heed at http://pastebin.com/20CmHQ7Y > Speaking for myself, I would be include to recast this code: > > @absolutize > def addition(a, b): > return a + b > > into: > > def _addition(a, b): > return a + b > > addition = absolutize(_addition) > > Then you can unit test both _addition() and addition(). > > And so forth. > > Cheers, I have to admit I'm having a hard time understanding why you'd need to test the undecorated functions. After all, the undecorated functions aren't available to anyone. All that matters is how they behave with the decorators. But my imagination is weak: do you mind explaining more about what the functions do, what the decorators do, and why you need to test the undecorated functions? I'll learn something, and with more information, we might be able to find a better solution. --Ned.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Skipping decorators in unit tests Gilles Lenfant <gilles.lenfant@gmail.com> - 2013-10-10 07:00 -0700
Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-11 09:12 +1100
Re: Skipping decorators in unit tests Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-11 02:55 +0000
Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-11 14:13 +1100
Re: Skipping decorators in unit tests Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-11 04:36 +0000
Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:23 -0400
Re: Skipping decorators in unit tests Ben Finney <ben+python@benfinney.id.au> - 2013-10-11 14:42 +1100
Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:17 -0400
Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:25 -0400
Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:32 -0400
Re: Skipping decorators in unit tests Ethan Furman <ethan@stoneleaf.us> - 2013-10-11 10:51 -0700
Re: Skipping decorators in unit tests Ned Batchelder <ned@nedbatchelder.com> - 2013-10-10 19:44 -0400
Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-10 21:12 -0400
Re: Skipping decorators in unit tests Gilles Lenfant <gilles.lenfant@gmail.com> - 2013-10-11 02:37 -0700
Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-12 08:38 +1100
csiph-web