Dugan Chen's Homepage

Various Things

Unit Testing PyQt Applications With Nose and Mock

I spent a couple of evenings getting familar with the Mock mocking framework for Python. Turns out it works very well for testing PyQt code. Let’s say you have the following program, which I just contrived up. It’s very contrived, because it ignores obvious and simpler implementations such as using the QWebView‘s setUrl method. Nevertheless, […]

Implementing Pythonic mixins with class decorators.

There was virtually no discussion following the posting of this PEP, meaning that everyone agreed it should be accepted. Here is the correct and Pythonic way to do mixins in Python. You don’t. You use class decorators to do the same thing. Note that class decorators were added to Python as of 2.6. I suspect […]