[Tutor] Class tests
Mon, 15 Jan 2001 09:19:24 -0000
> I have just finished coding a class withe several class methods, can
> someone show me how to programmatically test each function in
> the class safely?
Depends on how you define programmatically.
I'd suggest the python interactive prompt...
>>> c = Foo()
>>> print c.someAttribute
>>> print c.anotherAttribute
Once you are happy it works you could put those tests in
a "test" function for future regression testing:
c = Foo()
# ... etc
and have the usual stanza:
if __name__ == "__main__": test()
If you are using IDLE you can save your interactive session then
edit out the prompts etc in Notepad or whatever...