<div dir="ltr">Mocking is nice and easy for this, and it&#39;s important to have some unit-tests for this one.<div><br><div>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.</div>

<div><br></div><div>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.</div><div>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.</div>

<div><br></div><div>This way you can predict how your process behaves and when it should be killed, and test for it.</div><div><br><div class="gmail_quote">On Tue, Jun 7, 2011 at 3:25 AM, John Anderson <span dir="ltr">&lt;<a href="mailto:sontek@gmail.com">sontek@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I wrote this script that monitors memory usage of processes and kills them if they get too high.  I&#39;m having a hard time figuring out how to test something like this.<div>

<br></div><div>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&#39;m thinking about doing but would like to hear other peoples opinions!</div>
<br>_______________________________________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
<br></blockquote></div><br></div></div></div>