[Twisted-Python] Twisted Trial changes working directory
Jean-Paul Calderone
exarkun at divmod.com
Fri Jul 3 09:26:48 MDT 2009
On Fri, 3 Jul 2009 10:17:12 -0400, Gerrat Rickert <grickert at coldstorage.com> wrote:
>I have a (Twisted) program that saves & uses a file in the current
>working directory.
>When running tests for the program, Trial changes the working directory,
>causing this file to be written into the '_trial_temp' directory
>instead.
>...so the program works differently when run via Trial vs. in normal
>use.
The only difference I can infer from your description is whether the file
in question is created in the directory you invoke the program from (in
the non-trial case) or in the _trial_temp subdirectory of that directory
(in the trial case). It's not obvious to me why this might be a problem.
>
>There are a number of solutions to this, but I'd just like to understand
>the reasoning behind this surprising behaviour.
>The docs say that this: "...allows them to write whatever data they like
>to disk, and not worry about polluting the current working directory"
>...couldn't they just do this without changing the working directory?
This is an ancient feature of trial, from the days when Twisted's own test
suite (the primary driver of trial development for many years) was even
more crufty than it is today. In those days, many tests just created files
in the working directory. The _trial_temp feature provided a single fix
which addressed the mess created by all of the tests in one fell swoop. The
behavior is still convenient for tests which aren't written carefully in
this regard.
Jean-Paul
More information about the Twisted-Python
mailing list