testing/mozbase/mozrunner/tests/test_start.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mozbase/mozrunner/tests/test_start.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +#!/usr/bin/env python
     1.5 +
     1.6 +import os
     1.7 +from time import sleep
     1.8 +import unittest
     1.9 +
    1.10 +import mozrunnertest
    1.11 +
    1.12 +
    1.13 +class MozrunnerStartTestCase(mozrunnertest.MozrunnerTestCase):
    1.14 +
    1.15 +    def test_start_process(self):
    1.16 +        """Start the process and test properties"""
    1.17 +        self.assertIsNone(self.runner.process_handler)
    1.18 +
    1.19 +        self.runner.start()
    1.20 +
    1.21 +        self.assertTrue(self.runner.is_running())
    1.22 +        self.assertIsNotNone(self.runner.process_handler)
    1.23 +
    1.24 +    def test_start_process_called_twice(self):
    1.25 +        """Start the process twice and test that first process is gone"""
    1.26 +        pid1 = self.runner.start()
    1.27 +        # Bug 925480
    1.28 +        # Make a copy until mozprocess can kill a specific process
    1.29 +        process_handler = self.runner.process_handler
    1.30 +
    1.31 +        pid2 = self.runner.start()
    1.32 +
    1.33 +        try:
    1.34 +            self.assertNotIn(process_handler.wait(1), [None, 0])
    1.35 +        finally:
    1.36 +            process_handler.kill()
    1.37 +
    1.38 +    def test_start_with_timeout(self):
    1.39 +        """Start the process and set a timeout"""
    1.40 +        self.runner.start(timeout=2)
    1.41 +        sleep(5)
    1.42 +
    1.43 +        self.assertFalse(self.runner.is_running())
    1.44 +
    1.45 +    def test_start_with_outputTimeout(self):
    1.46 +        """Start the process and set a timeout"""
    1.47 +        self.runner.start(outputTimeout=2)
    1.48 +        sleep(5)
    1.49 +
    1.50 +        self.assertFalse(self.runner.is_running())

mercurial