Help with python code!
Roy Smith
roy at panix.com
Sun Mar 31 17:08:10 EDT 2013
In article <37f23623-8bf5-421a-ab6a-34ff622c69f1 at googlegroups.com>,
jojo <gerrymcgovern at gmail.com> wrote:
> Hi - I am a newbie to python and was wondering can someone tell me what the
> following code does. I need to figure out how to test it
I know this is going to sound unhelpful, but if your task is to test the
code, what good does it do to know what it does? Clearly, it does what
it does. What you really want to know is "What is it *supposed* to do?"
Until you know what it's supposed to do, it is meaningless to even think
about testing it.
Seriously. I'm not trying to make life difficult for you. I've seen
too much time and effort wasted on useless testing because there wasn't
any specification for what the code was supposed to do.
I will give you one hint, however. You've got stuff like:
for line in os.popen(cmd).readlines():
line = line.rstrip()
This is a syntax error because the indenting is wrong. Unlike C#,
indenting is significant in Python. I don't know if the code you've got
really is indented wrong, or it's just an artifact of how you posted it.
But before anything else, you need to sort that out.
Unless, of course, the specification for this code is, "It is supposed
to raise IndentationError", in which case it passes the test :-)
More information about the Python-list
mailing list