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


Groups > comp.lang.python > #12234

Re: Unit test failing please help

Subject Re: Unit test failing please help
From Tim Wintle <tim.wintle@teamrubber.com>
References <ccbce61b-77e3-44fc-bbb8-fbd7007326dd@w28g2000yqw.googlegroups.com>
Organization Team Rubber
Date 2011-08-26 16:52 +0100
Newsgroups comp.lang.python
Message-ID <mailman.449.1314376532.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, 2011-08-26 at 08:35 -0700, lblake wrote:
> Hi I am new to python I am at bit lost as to why my unit test is
> failing below is the code and the unit test:
> 
> class Centipede(object):
>     legs, stomach

This doesn't do what you think it does.

"legs, stomach" is a statement and is not defining any variables at all.

Presumably you've also got variables named legs and stomach in the
module's scope - as I'd expect to see a NameError : name 'legs' is not
defined.

(I'd also expect a SyntaxError from having an empty __init__ function
body)

You probably want do write something like this:

class Centipede(object):
    def __init__(self):
        self.legs = []
        self.stomach = []

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


Thread

Unit test failing please help lblake <treleven.lloyd@gmail.com> - 2011-08-26 08:35 -0700
  Re: Unit test failing please help John Gordon <gordon@panix.com> - 2011-08-26 15:58 +0000
  Re: Unit test failing please help Tim Wintle <tim.wintle@teamrubber.com> - 2011-08-26 16:52 +0100

csiph-web