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?
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?