'Python' Tag

  • Jul
    08
    2010

    How to run a single unit test/unit test module with py.test

    Note to self: It is actually possible to select a single test module or a single test function in py.test.
    But passing the file name as argument to a py.test invocation selects only the doctest from that file (wtf!?). Instead, you need to call it like this:
    12$ py.test -k test_module    # to run the tests [...]

  • Jul
    05
    2010

    Postprocessing conference videos

    I was planning to attend DebConf New York this year, but for a number of reasons I decided not to go. Fortunately, Ferdinand Thommes organized a MiniDebConf in Berlin at LinuxTag and I managed to attend. Thanks, Ferdinand!
    There were a number of interesting Talks. I especially liked the talk of our DPL, and those about [...]

  • Dec
    23
    2009

    Hitting the dynamic linker wall…

    I was working on replacing some mockup code for testing an internal library with python. Basically, the C code is incredibly big and I would rather mock the 3rd party API we are using in python. I wrote a generator to create wrapping code that forwards the C API calls to my python module.
    Now that [...]

  • Oct
    16
    2009

    Passing optparse results as keyword arguments

    The python optparse package is really handy for parsing command line arguments. When combining this with an extra main function idiom (to allow interactive usage or use as a module), I ran into a small problem – the following code does not run:
    123456789def main(foo, bar):
        print("foo: %s, bar: %s\n" % (foo, bar))
    if __name__ == [...]

  • Feb
    20
    2009

    Reading an arbitrary file as python module source

    Not sure if anybody will ever need this. I just found out because I did not accept that I can’t load my Subversion pre-commit hook as a module.
    Of course it is actually quite simple:

    import imp
    hook = imp.load_source(“hook”, “pre-commit”)

    It’s that easy. Now I can test the internal functions from ipython before letting it wreck our repository. [...]

 
Powered by Wordpress and MySQL. Theme by openark.org