1

I'm using squish to test a qt application. The problem is that squish does not support threads:

http://kb.froglogic.com/display/KB/Article+-+Using+Threads+in+Python

However, I need to use threads since I need to communicate periodically with the application under test via tcp.

I have a script which does the following in its main thread:

squishtest.waitForObject(":My_Button")
squishtest.waitForObject(":My_Button")

These squish commands will close two dialogs which popup when I start the application. While, each squish command is executing I have indeed noticed that all my tcp threads (threading.Thread) are blocked until the squish command returns. I cant test the application under test if the threads are blocked in this manner. Therefore I felt I could use the multiprocessing module to solve this problem, so I tried:

p = Process(target = squishtest.waitForObject, args = (":My_Button",))
p.start()
p.join()

This works fine however when I tried:

p = Process(target = squishtest.waitForObject, args = (":My_Button",))
p.start()
p.join()

p = Process(target = squishtest.waitForObject, args = (":My_Button",))
p.start()
p.join()

I see the following text being outputted on the command line where I execute python:

RemoteInspector(0x0x8702b28)::type: Invalid class id 493 for appid 156850424

What does this mean?

I then tried, for the sake of it, this:

p = Process(target = squishtest.waitForObject, args = (":My_Button",))
p.start()
p.join()

squishtest.waitForObject(":My_Button")

and this time I also get a coredump from python:

RemoteInspector(0x0x81b5ac8)::type: Invalid class id 493 for appid 156850440
Aborted (core dumped)

What might the issue be here? Is my approach to solving the fact that squish blocks my threads a sensible one? Can you suggest another approach?

I'm using python 2.6.

Baz
  • 12,713
  • 38
  • 145
  • 268
  • I don't know anything about squish, but it sounds like its main job is trying to talk natively to GUI objects owned by the current process, which isn't going to work if those objects are in another process. – abarnert May 27 '15 at 07:58
  • Also, have you considered re-architecting your app so the networking happens in a separate child process(es) from the GUI? Then squish can do whatever it wants to the GUI and it won't interfere with the networking. (And there are other advantages to that kind of design… unless you're using Qt's networking stuff, in which case, never mind…) – abarnert May 27 '15 at 08:00
  • @abarnert I'm testing a qt application via a python script by importing the squish module. Squish starts the application under test and when I do a ps I see this application as its own process. Of course python also appears as its own process. Are you suggesting that I communicate with the application under test via processes instead of threads? I obviously cant re-architect the application under test :). My concern here is that I would like to change the behaviour of the tcp communication from my tests in order to test the app in different ways. Not sure how easy that will be with processes. – Baz May 27 '15 at 08:11
  • Again, I don't know anything about squish, but you're explicitly kicking off its tasks in a child process (by using `multiprocessing.Process`), and it pretty clearly wants to stay in a single process. The exceptions are most likely because it's trying to look directly at some objects that it stored in the parent process's space and that aren't available in the child process's space. – abarnert May 27 '15 at 08:14
  • By the way, any library whose documentation says "Python's threads are not real operating system threads but emulated by the interpreter" doesn't seem very reliable. Python's threads _are_ real operating system threads. There's no code anywhere in the CPython interpreter to emulate threads. (Except for an OS that doesn't have threads, but the "emulation" there just quits if you try to start a second thread, which I wouldn't call an amulation…) – abarnert May 27 '15 at 08:16
  • Thanks @abarnert. I will try creating a process in which I execute all my squish commands and see if I have more luck. – Baz May 27 '15 at 08:45

0 Answers0