doctest Hassles!
Jason Orendorff
jason at jorendorff.com
Tue Mar 12 13:20:46 EST 2002
Douglas Garstang wrote:
> Well, when I print the value of ls, I get:
>
> [...]
>
> Notice the blank line at the end. Where did that come from?
print x always writes x, followed by a newline.
> Also, why is the output in ONE column instead of across
> the screen (as in a normal ls) when spawnv is used? All I did was
> print the output of the ls command, but the output is different.
"ls" has this quirk. If it finds that stdout is a tty, then it
spits out nice columns. Otherwise, one file per line. I think GNU
"ls" has command-line options that allow you to specify which mode.
"ls -1" forces one column.
Several Unix utilities do this sort of tty detection.
I rather dislike it (except in Python of course). But that's life.
> On a side note, I've had this problem before with python,
> trying to read text config files. As soon as it hit an empty
> line, reading would stop! Huh?
Could you clarify this? Is this a separate problem?
Do you have source code that illustrates this?
> What am I missing here? I would imagine that executing external
> programs is central to testing, but it seems to be _really_ difficult.
Doctest isn't designed for stuff like this, and there are some
limitations to what it can do.
Anyway, try os.listdir(os.curdir) and save yourself some trouble. :)
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list
mailing list