Unit testing daemon creation

B

Ben Finney

Howdy all,

I'm in the process of creating a daemon program using Python. I know
that the program needs to 'os.fork()', then branch based on the return
value and either exit (if the parent) or continue (if the child).

How can I unit test that? That is to say, how can I programmatically
test that functionality of daemonisation from an external module which
imports the daemon module for testing?

I could be hackish and simply clobber the existing 'os.fork' for the
purpose of the unit test, making a stub function that returns the
appropriate values for the test. Is there a better way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top