How to test?

Manfred Lotz ml_news at posteo.de
Fri Apr 24 16:35:54 EDT 2020


On 24 Apr 2020 20:17:04 GMT
ram at zedat.fu-berlin.de (Stefan Ram) wrote:

> Manfred Lotz <ml_news at posteo.de> writes:
> >I have a command like application which checks a directory tree for
> >certain things. If there are errors then messages will be written to
> >stdout.  
> 
>   Error messages should be written to sys.stderr.
> 

Yes. But for testing it doesn't matter if it is written to stdout or
stderr.


> >How to test this in the best way?  
> 
>   The functions that check the tree should not write to
>   the console. Instead, when an error occurs they 
> 
>       - raise an exception,

This would be bad. In my case I want to report all the errors to
somebody else. An exception means I don't see more errors which
may have occured.


>       - yield an error information, 

Hm, you mean the check function would be something like an iterator.
Sounds interesting.

>       - return an error information, or

I think this is harder to implement.

>       - call a callback with the error information.
> 
>   Their callers than can be either high-level console code,
>   that writes those information to a console, or test code.
> 

This is also very interesting.


So, I think yield or callback are the ideas I have to investigate.


Thanks a lot.

-- 
Manfred







More information about the Python-list mailing list