In this post, I’m discussing the stub implementation that I will use to set up the testing frameworks.
I’ve got my markdown.py requirements written.
An initial set, at least. Enough to get me started.
I want to move on to explore testing frameworks and testing strategy.
But to do that, it will be helpful to have something to test. So I’m going to write a stub for my script. Something that has the right name and interface. I can use it just as I will use the completed script. It just doesn’t work yet.
What’s the stub have to do:
- be a callable command line script
- accept input through stdin
- accept a file name argument
- print at least something to stdout
That’s really it.
Now I can use this stub to look at test frameworks and start writing tests.
So here is a reasonable stub.
# Markdown.py # First attempt # - just print whatever is passed in to stdin # - if filename passed in, print file instead of stdin import fileinput for line in fileinput.input(): print line, # print the line, the comma says don't add a newline
I will go ahead and check this in to version control.
Next, a look at frameworks.
Normally, I’d already have a test framework chosen.
But that’s kind of the point of this blog. At least to some extent.
I’ll take a look at pytest, nose, and the built-in python unittest.
I know doctest is also available and built-in. However, I don’t think I’ll look at it for a general purpose functional test framework. This may be shortsighted. Please let me know if you think leaving it out is a mistake.
Please leave a comment or contact me otherwise if there is some other framework I really ought not to forget.