Serializing non-qualified attributes with ElementTree

Posted on Mon 21 November 2011 in Coding • Tagged with elementtree, hack, python

The other day, I had a piece of Python code that deserialized an XML text containing a UPnP service description to an ElementTree instance using ElementTree.parse, then at a later stage serialized it back to XML using ElementTree.write.

Now, the service description happened to contain non-qualified attributes (like …


Continue reading

On discovering Test-Driven Development

Posted on Sat 01 October 2011 in Coding • Tagged with TDD

Test-Driven Development (TDD) is a programming practice that to me is an immensely useful quality assurance tool. In brief, TDD is about writing unit tests first and letting the unit tests drive the design of your code. Some of the most important benefits are:

  • The public API your create becomes …

Continue reading

Test data provider using Python metaclass

Posted on Sat 01 October 2011 in Coding • Tagged with metaclass, Python, test

In my airpnp project, I had to write a binary plist parser in order to parse certain data posted by iDevices. To support my unit tests, I created a number of binary plist files using an existing tool. I ended up with 17 files, and quickly realized that I wanted …


Continue reading

Mocking Zope interfaces

Posted on Wed 28 September 2011 in Coding • Tagged with mock, test, python

In one of my pet projects I use Twisted for handling asynchronous network events. While browsing the Twisted source code, I encountered Zope interfaces. In a dynamically typed language like Python, what good are interfaces?

It turns out that Zope interfaces are slightly different from interfaces found in a statically …


Continue reading

Debugging Java focus problems using the focus log

Posted on Wed 28 September 2011 in Coding • Tagged with Java

A while ago I set out to fix a couple of focus problems in a GUI at work. One of the problems was that after a certain user operation, all keyboard shortcuts stopped working (as you may know, keyboard events are dispatched up the focus chain until a component handles …


Continue reading