#NEWLINE# def test( tmpdir ) : #NEWLINE# #INDENT# if ( not ( os . name == 'posix' ) ) : #NEWLINE# #INDENT# pytest . skip ( 'Cannot run test on a non-POSIX platform.' ) #NEWLINE# #UNINDENT# tmpdir . ensure ( '.pid' ) #NEWLINE# tmpdir . ensure ( '.signal' ) #NEWLINE# pidfile = str ( tmpdir . join ( '.pid' ) ) #NEWLINE# signalfile = str ( tmpdir . join ( '.signal' ) ) #NEWLINE# args = [ sys . executable , signalapp . __file__ , pidfile , signalfile ] #NEWLINE# cmd = ' ' . join ( args ) #NEWLINE# p = Popen ( cmd , shell = True , env = { #NEWLINE# #INDENT# 'PYTHONPATH' : ':' . join ( sys . path ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# status = p . wait ( ) #NEWLINE# assert ( status == 0 ) #NEWLINE# sleep ( 1 ) #NEWLINE# assert os . path . exists ( pidfile ) #NEWLINE# assert os . path . isfile ( pidfile ) #NEWLINE# f = open ( pidfile , 'r' ) #NEWLINE# pid = int ( f . read ( ) . strip ( ) ) #NEWLINE# f . close ( ) #NEWLINE# kill ( pid , SIGTERM ) #NEWLINE# wait ( pid ) #NEWLINE# f = open ( signalfile , 'r' ) #NEWLINE# signal = f . read ( ) . strip ( ) #NEWLINE# f . close ( ) #NEWLINE# assert ( signal == str ( SIGTERM ) ) #NEWLINE# remove ( pidfile ) #NEWLINE# remove ( signalfile )