Python Programming, news on the Voidspace Python Projects and all things techie.


emoticon:nightmare 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. Laughing

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.

def decorator(func):
    """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. Smile

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 ? Confused

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 it.

Posted by Fuzzyman on 2006-05-18 13:45:42 | |

Categories: ,

New IronPython Home

emoticon:ghostradio IronPython, has a new home... almost. Smile

IronPython on Codeplex

There's not much there yet. So is Codeplex Microsoft's answer to sourceforge ?


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... Wink

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-05-16 13:57:33 | |

Categories: , , , ,

Hosted by Webfaction