Re: Parser Fragility

will kahn-greene <[email protected]> Sat, 08 May 2010 14:48:54 -0400
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Whoops!

I meant to reply to this email and walk you through writing tests, but I
wrote the item in my todo list wrong.

Anyhow, I just pushed a fix that allows metadata items to have no value.
 Instead of using an empty string, I made the default value "1".  This
allows plugin developers to use these as flags:

    if entry_dict.get("noacronyms"):
       ...

The default here is None which is a False-like value.  A "1" is a
True-like value, so a metadata item with no key acts as a True-like
value which allows you to do if blocks like the above.

I also added some basic blosxom_entry_parser tests including one for
metadata with no values.

All this is in:

http://gitorious.org/pyblosxom/pyblosxom/commit/3494b6bd7fb29133cf72801c5fafe79040ca4640

I'll write an email about PyBlosxom testing in another email.  Coming soon!

/will


On 05/04/2010 11:12 AM, Sebastian Spaeth wrote:
> On 2010-05-04, will kahn-greene wrote:
>> I think this looks ok but it'd be good to provide a test in the test
>> suite for it.
>>
>> So, if you want, you could push the test with the fix or alternatively,
>> I can take some time to write a test.
> 
> I have never written a python unittest before, so I would appreciate
> some support here, yes. If you write a test, I can push the fix and
> verify that it works as intended.
> 
> It would be interesting to see what is needed for a new test.
> 
>> I should document that.  What happens is the second #tags value
>> overrides the first--there's no multidict thing going on here.
> 
> Right, that would be good to have it documented somewhere.
> 
> Sebastian

------------------------------------------------------------------------------