Showing posts with label package. Show all posts
Showing posts with label package. Show all posts

Wednesday, December 10, 2008

New boduch Python library.

I've made a new Python library called boduch available on pypi. Why did I call it boduch? Because it is simply a Python package where I can publish any cool Python tools and I couldn't think of a better name.

The current version has my first attempt at an event publishing system. Here is an example usage scenario.

#Event example using boduch.event

from boduch.event import Event, publish, subscribe, lock, unlock
from boduch.handle import Handle

class MyHandler(Handle):
def __init__(self, *args, **kw):
Handle.__init__(self, *args, **kw)

def run(self):
print "Got event",self.data["event"]

if __name__=="__main__":
subscribe(Event, MyHandler)
publish(Event)

Here, we have defined a simple handler that prints out the event it received. In the main program, we subscribe our handler to the base Event. We then publish our event.

Monday, December 8, 2008

Distributing unit tests.

In this context, I'm referring to distributing unit tests along with a software package, as opposed to executing unit tests in a distributed fashion (which is an interesting topic in its' own right). Unit testing has proven to be an essential development artifact to ensure all use cases are executed correctly. I wish I could say all open source projects distribute unit tests as a component of the package. This is simply not the case. Several projects do, however, include a testing facility which is usually composed of unit tests.

Why, if the authors of these software packages spend time writing all these unit tests, should they be distributed along with the software? After all, they write these unit tests for their own testing. Sometimes an entire testing team is responsible for this task.

I would say that no matter how big a testing team any given project has, they are never going to cover all possible corner cases. That goes without saying (but I'm saying it anyway). Custom operating environments, even some other piece of installed software, could cause unexpected behavior that is in no way handled correctly be the software in question. At least having unit testing available in these situations can offer some clue.