Recently I’ve been using IronPython as a dynamic testing framework for .Net assemblies more and more. Particularly in the current development iteration for our company’s website, where a contractor is working on the data access layer classes for a database schema of my design. In order to test his data access methods I need to new up an instance of the various classes and check the output of the methods. We’re simultaneously starting to do some coded integration tests using NUnit for the same purpose, but when I just want to quickly smoke-check his work before sending him on to the next task, opening an IronPython console and instantiating his class and running through the methods can’t be beat for quickness. I’ve been meaning to write a little bit more about this, but suffice it to say it’s been working really well for me.My typical usage pattern is to import the clr and add a reference to the dll in question by path and filename, and then to import just the class I want to test. So far, so good. But when testing a little refactoring I was doing this morning I encountered an error message that took me a few minutes to isolate and resolve. The call I was using was
And the error message I saw was:
I stared at the code for a while, swearing up and down that the method I was calling *did* have a 1 argument overload available. Finally I realized that I was calling an instance method in a static fashion – the other argument that IronPython was expecting was an instance of the class to execute the method on. Not exactly rocket science, but a confusing (to me, at least) error message that took me longer than it should have to figure out.
TypeError: LoadSimpleCategoriesByRegion() takes exactly 2 arguments (1 given)