Handling test data that depends on temporal data (that might change while the test runs)

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu May 15 22:31:55 EDT 2008


En Thu, 15 May 2008 22:50:21 -0300, Marcelo de Moraes Serpa  
<celoserpa at gmail.com> escribió:

> Hmm.. I re-read your message and I think I'm approaching testing in a
> mechanical way, indeed.
>
> You're right, my test is kind of pointless, given the objective of the
> function, which is to generate a differnt directory name each time it is
> called. I also found it kind of strange to repeat the implementation in  
> the
> test method. However, something keeps telling me that it still has to be
> "unit" tested, sonehow (the algorith used).

Again, that depends on the actual purpose of such function. If all you  
want is a unique directory name, you might consider the set of users and  
time as "hints" only; a completely random directory name would be OK. You  
might not even require that the same input generates always the same  
output. The less restrictions you put on the required behavior, the  
easiest is to replace the current implementation. Of course, if you *do*  
require some invariant or some condition, you have to test for it.

-- 
Gabriel Genellina




More information about the Python-list mailing list