"finally" for unit test

Jorgen Grahn grahn+nntp at snipabacken.dyndns.org
Fri Mar 23 10:48:32 EDT 2007


On 23 Mar 2007 12:19:15 GMT, Duncan Booth <duncan.booth at invalid.invalid> wrote:
> "killkolor" <gabriel.hase at gmail.com> wrote:
>
>> I have a unittest framework that tests a single function that in turn
>> works with files (takes input and outputs in the same file, no return
>> values).
>
> I would want to split that function into two:
>
> a) one which does the processing, but not working with a file,

Better to make it work with "a file", in the sense that it works with
file-like objects so you can feed and leech it using StringIO.

> b) and one which handles reading and calls the processing function and then 
> writes the file. The function it calls would be passed in as an optional 
> parameter and defaults to function (a)

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.dyndns.org>  R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list