The Python doctest module rocks. Lately, I have been using it to write unit tests for Crunchy: for each module, I write a reStructuredText file which contains sample tests written as simulated interpreter sessions, using doctest.testfile(). This has worked really well in general ... however, I have encountered one small annoyance, which I managed to get rid of in an "elegant" way using Monkeypatching. doctests allow the use of directives. One "powerful" directive is the ELLIPSIS directive. Quoting from the documentation: When specified, an ellipsis marker (...) in the expected output can match any substring in the actual output. This includes substrings that span line boundaries, and empty substrings, so it's best to keep usage of this simple. Complicated uses can lead to the same kinds of "oops, it matched too much!" surprises that .* is prone to in regular expressions. Unfortunately, I encountered a case where the ellipsis marker did not allow enough matching! Consider the following situation: I have a program (Crunchy!) that saves the user's preferences Read the full article
Comments (0)
Add Your Comment
Please Enter your Email ID,
to get a new password
Add something
Snip
News
Site
Add Snip
Adding a Snip...
Now you can import your favorite sites to your socialmedian page
Loading...
Loading...
Is this you?
Stats
Mood
0%
Like
0%
Dislike
Share this story
Network
Email
Tweet
Share with the News Network
Email ID's
(multiple Email ID's separated by commas)
Message
Also post this message as a public comment
Don't worry. We won't share the name or email address of the person that you sent the story to.