[Tutor] I don't get it

Sean 'Shaleh' Perry shalehperry@attbi.com
Fri, 20 Sep 2002 11:47:32 -0700


On Friday 20 September 2002 11:39, Erik Price wrote:
> On Friday, September 20, 2002, at 01:53  PM, Magnus Lycka wrote:
> > Regarding use of "if __name__ =3D=3D '__main__':" I usually
> > place my test code in separate files. For moduleX.py
> > I will have a moduleX_ut.py. I then have a small script
> > that will run all the test scripts in a project directory.
>
> So... assuming I place each class in a different file, then I should
> have a complementary file that imports the class and runs through the
> gauntlet of methods, making sure each one does what it's supposed to do=
?
>
> Excellent.  I will implement this in my current project.
>

right for a trivial case:

def div(top, bottom):
    return top / bottom

def test_div():
    ret =3D div(0,1)
    assert(ret =3D=3D 0)

    try:
        ret =3D div(1,0)
    except:
        pass
    else:
        assert(0) # should have thrown an exception

    ret =3D div(4,2)
    assert(ret =3D=3D 2)
#end test_div

In other words try a few boundary conditions and then a few real cases.