[TIP] How would you test something that deals with processes?

Yoni Tsafir yonix85 at gmail.com
Tue Jun 7 00:01:48 PDT 2011


Mocking is nice and easy for this, and it's important to have some
unit-tests for this one.

I would personally add an integration test, that runs a real process,
because you usually want to test that your interface to the OS is correct as
well.

The best process to run is some kind of python or shell script that you can
predict its behavior. For instance a C process that allocates a certain
amount of memory each 10 seconds, etc.
You can also catch the kill signal and have the process print some kind of
error to stderr if it thinks it caught the signal at the wrong time, etc.

This way you can predict how your process behaves and when it should be
killed, and test for it.

On Tue, Jun 7, 2011 at 3:25 AM, John Anderson <sontek at gmail.com> wrote:

> I wrote this script that monitors memory usage of processes and kills them
> if they get too high.  I'm having a hard time figuring out how to test
> something like this.
>
> Would you just mock out the process list and test that if you pass it a
> process list it calls send_signal?  Thats what i'm thinking about doing but
> would like to hear other peoples opinions!
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20110607/3975980a/attachment.htm>


More information about the testing-in-python mailing list