Unit testing daemon creation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Finney

    #1

    Unit testing daemon creation

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

    --
    \ "Beware of and eschew pompous prolixity." -- Charles A. |
    `\ Beardsley |
    _o__) |
    Ben Finney

Working...