[TIP] cleanUp for unittest

Fred Drake fdrake at gmail.com
Tue Apr 7 09:30:34 PDT 2009


On Tue, Apr 7, 2009 at 11:58 AM, Olemis Lang <olemis at gmail.com> wrote:
>> This relies on Python's garbage collector implementation details (i.e.
>> refcounting),
>
> That's th idea ;)

This seems to make it very easy to create fragile fixtures
unintentionally, since not all Python implementations share the same
garbage collection semantics.

> - As I said, the semantics for resource proxies is that they control
> access to the underlying resource as long as they are loaded in
> memory. If you want to discard'em call (force?) GC .
>
> - If you want to control shared access to your resources, then it is
> very posible that you might want to use either GoF Singleton or
> ParametricSingleton pattern to implement the proxy classes ( there is
> actually an article in JOT about using ParametricSingleton to control
> access to shared RMI registries ;)

While this seems reasonable on the face of it, it really adds more
complexity.  This is the result of needing more code to properly
manage the resource allocation than what's needed just to tear it
down.  Add to that the loss of determinism, and there's no real win
that I can see.

A simple stack of cleanup operations is just drop-dead simple, so is
hard to beat.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
"Chaos is the score upon which reality is written." --Henry Miller



More information about the testing-in-python mailing list