I am new to python and trying to set up a functional test environment. The test environment should receive DBus signals and evaluate them. The DBus signal uses GLib MainLoop. I have the following class encapsulating a loop:
class SignalLoop(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.__l = gobject.MainLoop() def run(self): self.__l.run() def quit(self): self.__l.quit()
and in the module that executes DBus processing, I tried:
class __ModuleInitializer: def __init__(self): print('Module was initialized') gobject.threads_init() sl = SignalLoop() sl.start() def __del__(self): print('Module was deinitialized') sl.quit() __module_init = __ModuleInitializer()
I also tried the following:
- setUp / tearDownModule () doesn't work for me - at least in python 2.5.2
- __ init __ () and __del __ () and putting all the test windows in one class. __del __ () is never called, and this solution will not scale with a lot of test cases.
When I run the code, sl.qui () is never executed, and I don't know why. I have to kill my master when starting from the console, because it never returns. However, this is not a problem for the test runner PyDev.
Is there any hook that I can use to destroy the test environment? I want to be able to run one test and a couple of tests, so "hacking" it in the methods themselves is not an option.
Can you help me?
source share