File: test_process.py

package info (click to toggle)
pyqonsole 0.2.0-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 448 kB
  • ctags: 647
  • sloc: python: 4,383; ansic: 111; makefile: 52; sh: 2
file content (53 lines) | stat: -rw-r--r-- 1,742 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (c) 2005-2006 LOGILAB S.A. (Paris, FRANCE).
# Copyright (c) 2005-2006 CEA Grenoble 
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the CECILL license, available at
# http://www.inria.fr/valorisation/logiciels/Licence.CeCILL-V2.pdf
#
import unittest
import time

from pyqonsole import pty_, procctrl


class ProcessTC(unittest.TestCase):
    def setUp(self):
        self.process = p = pty_.PtyProcess()
        
    def test_base(self):
        p = self.process
        # process controller interaction
        self.failUnless(p in procctrl.theProcessController.process_list)
        # base attributes
        self.failUnlessEqual(p.running, False)
        self.failUnlessEqual(p.pid, None)
        self.failUnlessEqual(p.status, None)
    
    def test_start(self):
        p = self.process
        p.run('ls', ['/'], 'xterm', False)
        time.sleep(2)
        # after execution
        self.failUnlessEqual(p.running, True) # XXX
        self.failIfEqual(p.pid, 0)
        self.failUnlessEqual(p.status, 0)
        # process controller interaction
        #self.failUnless(not p in procctrl.theProcessController.process_list)

    def test_start_then_kill(self):
        p = self.process
        p.run('sleep', ['11'], 'xterm', False)
        p.kill(9)
        time.sleep(2)
        # after execution
        self.failUnlessEqual(p.running, True) # XXX
        self.failIfEqual(p.pid, 0)
        self.failUnlessEqual(p.status, 0) # XXX killed !
        # process controller interaction
        #self.failUnless(not p in procctrl.theProcessController.process_list)

        
if __name__ == '__main__':
    unittest.main()