Picky Picky Game: Tidying up the Python code
Having got the first working version of the Picky Picky Game, I have naturally now pulled it apart again. I decided that now it is in a state where it makes sense to try to package up a version for Adrian to try installing, I better think about getting the module and package names right, since it will be harder to change them later.
I have reorganized my Python classes in to their own
package pdc
(designed to prevent name collisions
with WWW-oriented packages by other people). I also
changed some of the file names—so that ‘import
httputils
’ becomes ‘from pdc import
www
’.
There is now a proper
unit-test
suite for the www
module (which has functions like urlDecode
,
urlResolve
, and xmlencode
). This is
easier to do for this odule than the others, which tend to
involve creating scads of HTML text which will be hard to check
for errors. For the URL-manipulating functions, the unit tests
turned out to be invaluable—there are a lot of corner
cases that I only sorted out because I had tests for
all of them.