Decorators
I used decorators for the first time a couple of days ago (at work) [1].
I was pleased (and surprised), that not only did I get the syntax right without looking it up, but it worked first time [2]. Hooray, bonus points for me.
It was a simple decorator for test methods in our home-brew unittest framework, it just prints the function name when it's called. This was so we could see exactly which test was freezing.
"""Prints the function (or method name) when called."""
name = func.func_name
def decorated(*args, **keywargs):
print name
return func(*args, **keywargs)
return decorated
We're now part-way through swapping all our tests over to the Python UnitTest framework. So this code isn't needed, but it was fun to play.
The biggest hassle in changing over, is that our framework followed the test parameter conventions of the Java unit test framework that the Resolver boss was familiar with. Tests had the following parameter order :
message, expected, actual
PyUnit has [3] :
first, second, message
Corrected from earlier, thanks to reader comments which are correct.
I thought the Python framework owed its heritage to the common Java unit-test framework ?
Oh well, four-hundred tests converted, only about twelve-hundred more to go.
| [1] | From IronPython. |
| [2] | Well, once I'd corrected the compulsory typo. |
| [3] | Yes we could have just wrapped the tests, but in the long run it would just cause confusion; especially if anyone joined us who was familiar with the normal ordering. |
Like this post? Digg it or Del.icio.us it. Looking for a great tech job? Visit the Hidden Network Jobs Board.
Posted by Fuzzyman on 2006-05-18 13:45:42 | |
New IronPython Home
IronPython, has a new home... almost.
IronPython on Codeplex
There's not much there yet. So is Codeplex Microsoft's answer to sourceforge ?
Update
In Michael Swanson's Blog, he quotes :
CodePlex is an online software development environment for open and shared source developers to create, host and manage projects throughout the project lifecycle. It has been written from the ground up in C# using .NET 2.0 technology with Team Foundation Server on the back end.
So, not that unlike sourceforge hey...
In totally unrelated news, it looks like there are at least two ways of running Mac OS X on an ordinary PC :
Maybe I don't need to buy a Mac mini after all, and can just build my own PC...
Like this post? Digg it or Del.icio.us it. Looking for a great tech job? Visit the Hidden Network Jobs Board.
Posted by Fuzzyman on 2006-05-16 13:57:33 | |
Categories: General Programming, Computers, Python, Hacking, IronPython
For buying techie books, science fiction, computer hardware or the latest gadgets: visit The Voidspace Amazon Store. If you're looking for a new techie job, try the Voidspace Tech Job Board. This is part of the Hidden Network of technology and programming jobs.

IronPython in Action


