sawyl: (Default)
[personal profile] sawyl
I spent a decent chunk of yesterday running one of my colleagues through my Unitree janitor script. In the process I noticed a rough edges that could have done with another coat of varnish, so this morning I got out my figurative paintbrush and started work on the making good.

As I was running through and tidying up the comments I had a brainwave. Why not merge the functionality tests into the comments and use doctest to run a complete regression on the module? So I did. And everything went swimmingly, right up until I added a set of tests for a modified command line parser object. The offending test went something like this:

>>> p = MyParser()
>>> p.add_option("-a")
<MyOption at 0x...: -a>

But every time I ran the test I got the following failure:

Expected:
<MyOption at 0x...: -a>
Got:
<MyOption at 0x4033a20c: -a>

Which would have been fine, except that, as per the manual, I'd specifically put in a set of ellipses to deal with the fact that the address was likely to differ. But what, it transpires, I'd missed was that the doctest needs to know to enable ellipses, either on a per test basis with a "#doctest: +ELLIPSIS" pragma directive tagged on to the specific test or by passing the correct flag to the appropriate doctest function, e.g.

from doctest import testmod, ELLIPSES
testmod(optionflags=ELLIPSES)

Rather embarrassingly, it took me almost an hour to work out what I was doing wrong...

Profile

sawyl: (Default)
sawyl

August 2018

S M T W T F S
   123 4
5 6 7 8910 11
12131415161718
192021222324 25
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 5th, 2026 03:47 am
Powered by Dreamwidth Studios