#NEWLINE# def test_simple( pyscript ) : #NEWLINE# #INDENT# script = pyscript ( "\n        import sys\n        import time\n        from daemonocle import Daemon\n\n        def worker():\n            time.sleep(2)\n\n        daemon = Daemon(worker=worker, prog='foo')\n        daemon.do_action(sys.argv[1])\n    " ) #NEWLINE# result = script . run ( 'start' ) #NEWLINE# assert ( result . returncode == 0 ) #NEWLINE# assert ( result . stdout == b'Starting foo ... OK\n' ) #NEWLINE# assert ( result . stderr == b'' ) #NEWLINE# result = script . run ( 'status' ) #NEWLINE# assert ( result . returncode == 1 ) #NEWLINE# assert ( result . stdout == b'' ) #NEWLINE# assert ( b'DaemonError: Cannot get status of daemon without PID file' in result . stderr ) #NEWLINE# result = script . run ( 'stop' ) #NEWLINE# assert ( result . returncode == 1 ) #NEWLINE# assert ( result . stdout == b'' ) #NEWLINE# assert ( b'DaemonError: Cannot stop daemon without PID file' in result . stderr )