testing/mozbase/mozrunner/tests/test_start.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/usr/bin/env python
michael@0 2
michael@0 3 import os
michael@0 4 from time import sleep
michael@0 5 import unittest
michael@0 6
michael@0 7 import mozrunnertest
michael@0 8
michael@0 9
michael@0 10 class MozrunnerStartTestCase(mozrunnertest.MozrunnerTestCase):
michael@0 11
michael@0 12 def test_start_process(self):
michael@0 13 """Start the process and test properties"""
michael@0 14 self.assertIsNone(self.runner.process_handler)
michael@0 15
michael@0 16 self.runner.start()
michael@0 17
michael@0 18 self.assertTrue(self.runner.is_running())
michael@0 19 self.assertIsNotNone(self.runner.process_handler)
michael@0 20
michael@0 21 def test_start_process_called_twice(self):
michael@0 22 """Start the process twice and test that first process is gone"""
michael@0 23 pid1 = self.runner.start()
michael@0 24 # Bug 925480
michael@0 25 # Make a copy until mozprocess can kill a specific process
michael@0 26 process_handler = self.runner.process_handler
michael@0 27
michael@0 28 pid2 = self.runner.start()
michael@0 29
michael@0 30 try:
michael@0 31 self.assertNotIn(process_handler.wait(1), [None, 0])
michael@0 32 finally:
michael@0 33 process_handler.kill()
michael@0 34
michael@0 35 def test_start_with_timeout(self):
michael@0 36 """Start the process and set a timeout"""
michael@0 37 self.runner.start(timeout=2)
michael@0 38 sleep(5)
michael@0 39
michael@0 40 self.assertFalse(self.runner.is_running())
michael@0 41
michael@0 42 def test_start_with_outputTimeout(self):
michael@0 43 """Start the process and set a timeout"""
michael@0 44 self.runner.start(outputTimeout=2)
michael@0 45 sleep(5)
michael@0 46
michael@0 47 self.assertFalse(self.runner.is_running())

mercurial