test_misc.py (1297B)
1 #!/usr/bin/env python 2 3 import os 4 5 import mozunit 6 import proctest 7 from mozprocess import processhandler 8 9 here = os.path.dirname(os.path.abspath(__file__)) 10 11 12 class ProcTestMisc(proctest.ProcTest): 13 """Class to test misc operations""" 14 15 def test_process_timeout_no_kill(self): 16 """Process is started, runs but we time out waiting on it 17 to complete. Process should not be killed. 18 """ 19 p = None 20 21 def timeout_handler(): 22 self.assertEqual(p.proc.poll(), None) 23 p.kill() 24 25 p = processhandler.ProcessHandler( 26 [self.python, self.proclaunch, "process_waittimeout.ini"], 27 cwd=here, 28 onTimeout=(timeout_handler,), 29 kill_on_timeout=False, 30 ) 31 p.run(timeout=1) 32 p.wait() 33 self.assertTrue(p.didTimeout) 34 35 self.determine_status(p, False, ["returncode", "didtimeout"]) 36 37 def test_unicode_in_environment(self): 38 env = { 39 "FOOBAR": "ʘ", 40 } 41 p = processhandler.ProcessHandler( 42 [self.python, self.proclaunch, "process_normal_finish.ini"], 43 cwd=here, 44 env=env, 45 ) 46 # passes if no exceptions are raised 47 p.run() 48 p.wait() 49 50 51 if __name__ == "__main__": 52 mozunit.main()