File: test_thread.py

package info (click to toggle)
pygobject 3.22.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,492 kB
  • ctags: 5,045
  • sloc: ansic: 20,987; python: 15,991; sh: 4,659; makefile: 569; xml: 31
file content (29 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (2)
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
# -*- Mode: Python -*-

import unittest
import testhelper

from gi.repository import GLib


class TestThread(unittest.TestCase):
    def setUp(self):
        self.main = GLib.MainLoop()

    def from_thread_cb(self, test, enum):
        assert test == self.obj
        assert int(enum) == 0
        assert type(enum) != int

    def idle_cb(self):
        self.obj = testhelper.get_test_thread()
        self.obj.connect('from-thread', self.from_thread_cb)
        self.obj.emit('emit-signal')

    def test_extension_module(self):
        GLib.idle_add(self.idle_cb)
        GLib.timeout_add(50, self.timeout_cb)
        self.main.run()

    def timeout_cb(self):
        self.main.quit()