File: test_subprocess.py

package info (click to toggle)
pygobject-2 2.28.6-12
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,076 kB
  • ctags: 7,116
  • sloc: xml: 20,728; ansic: 18,657; python: 16,282; sh: 11,109; makefile: 868
file content (24 lines) | stat: -rw-r--r-- 611 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
# -*- Mode: Python -*-

import sys
import unittest

import glib


class TestProcess(unittest.TestCase):

    def _child_watch_cb(self, pid, condition, data):
        self.data = data
        self.loop.quit()

    def testChildWatch(self):
        self.data = None
        self.loop = glib.MainLoop()
        argv = [sys.executable, '-c', 'import sys']
        pid, stdin, stdout, stderr = glib.spawn_async(
            argv, flags=glib.SPAWN_DO_NOT_REAP_CHILD)
        pid.close()
        glib.child_watch_add(pid, self._child_watch_cb, 12345)
        self.loop.run()
        self.assertEqual(self.data, 12345)