Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56635

Re: Skipping decorators in unit tests

Date 2013-10-11 13:22 +1100
From Cameron Simpson <cs@zip.com.au>
Subject Re: Skipping decorators in unit tests
References <52573BED.40305@nedbatchelder.com>
Newsgroups comp.lang.python
Message-ID <mailman.978.1381459605.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 10Oct2013 19:44, Ned Batchelder <ned@nedbatchelder.com> wrote:
> On 10/10/13 6:12 PM, Cameron Simpson wrote:
> >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(). [...]
> 
> 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.

If the undecorated function is buggy, the decorated function will
be buggy. But the bug will be harder to resolve, and if you're
especially lucky the decorator will often-but-not-always conceal
the bug in the inner function.

Wanting to test the core function is perfectly reasonable. You can in
principle write simpler and more direct tests of the core function.

Having an error report that points directly at an error instead of
an error report that points at some outer dysfunction (i.e. "somewhere
deep inside here something is broken") is highly desirable in
general, and therefore also in a test suite.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

They shouldn't get any new nuclear weapons until they've used the ones
they've got.    - Murff

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-11 13:22 +1100
  Re: Skipping decorators in unit tests Roy Smith <roy@panix.com> - 2013-10-10 23:01 -0400
    Re: Skipping decorators in unit tests Ethan Furman <ethan@stoneleaf.us> - 2013-10-11 10:46 -0700

csiph-web