1 Jul 2004 01:04
Re: testing new style class properties using pyUnit ?
Danny Yoo <dyoo <at> hkn.eecs.berkeley.edu>
2004-06-30 23:04:09 GMT
2004-06-30 23:04:09 GMT
On Wed, 30 Jun 2004, Duncan Gibson wrote:
> I had a class which used get and set methods to access a class variable.
> I set up some unit tests using pyUnit. After some fiddling about, I
> managed to get it all working.
>
> I've just upgraded the source to use the new style classes with
> properties instead of explicit get and set methods. However, so far I've
> been unable to convert the unit tests. I note the error message, but I
> don't understand why.
[some code cut]
Hi Duncan,
Ok,, what you're running into is actually not so much related properties
feature, but actually of the naming-mangling that Python does on any
property with leading double underscores.
In the 'A_new' class, you have the following methods:
> class A_New(object):
> __slots__ = ('__x',)
> def __init__(self, x=0):
> self.x = x
> def __get_x(self):
> return self.__x
> def __set_x(self, x):
> assert isinstance(x, int)
(Continue reading)
> At this point I'm very new to Python but I have read the tutorial in
the
> documentation, it seems very promising. At this moment I'm mainly
looking
> into Python to in hopes to develop a rendering management software.
>
> I apoligize in advance for the tons of newbie questions that will
follow,
> and thank you in advance for your time.
Thats OK, its what the list is for. If you read the official tutorial
you might be a wee bit more adbvanced a newbie than many of our
readers,
but you are welcome nonetheless.
Also if you know VBScript/JScript you might find my new online tutor
useful
since it teaches basic Python but using VBscript and JScript as
comparison
languages...
RSS Feed