How to write a functional test for a DBUS service written in Python?

前端 未结 6 1615
忘掉有多难
忘掉有多难 2021-01-02 01:16

(Title was: \"How to write a unit test for a DBUS service written in Python?\")

I\'ve started to write a DBUS service using dbus-python, but I\'m having trouble writ

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 02:04

    You could also start the mainloop in a separate thread very simply inside your setUp method.

    Something like this:

    import threading
    class BaseTestCase(unittest.TestCase):
        def setUp(self):
            myservice = MyDBUSService()
            self.loop = gobject.MainLoop()
            threading.Thread(name='glib mainloop', target=self.loop.run)
        def tearDown(self):
            self.loop.quit()
    

提交回复
热议问题