Permalink
Browse files

Add a callback test

  • Loading branch information...
1 parent c7affa4 commit c3eb5f2b6c3727c5629fe3edd6ef8cc03d650caf @oldpatricka oldpatricka committed Aug 18, 2012
Showing with 22 additions and 0 deletions.
  1. +22 −0 pidantic/nosetests/piddler_supd_basic_test.py
@@ -180,6 +180,28 @@ def restart_test(self):
assert int(new_pid) != 0
assert new_pid != original_pid
+ def state_change_callback_test(self):
+ global cb_called
+ cb_called = False
+
+ def my_callback(arg):
+ print "callback"
+ global cb_called
+ cb_called = True
+
+
+ tempdir = tempfile.mkdtemp()
+ factory = SupDPidanticFactory(directory=tempdir, name="tester")
+ pidantic = factory.get_pidantic(command="/bin/sleep 1", process_name="sleep", directory=tempdir)
+ pidantic.set_state_change_callback(my_callback, None)
+ pidantic.start()
+ state = pidantic.get_state()
+ while not pidantic.is_done():
+ factory.poll()
+ factory.terminate()
+
+ assert cb_called
+
if __name__ == '__main__':
unittest.main()

0 comments on commit c3eb5f2

Please sign in to comment.