unittests: Cannot load Gui module in console application.

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
teobo
Posts: 405
Joined: Fri Feb 21, 2014 11:23 am

unittests: Cannot load Gui module in console application.

Postby teobo » Sun Mar 06, 2016 5:50 pm

Hi,
tried to make a testsuite for stand alone macro code run, but get unexplained error message.
See the calling code below, see Testfile and module in linked post.

I am not just right now up to have gui testing for my stuff, but anyway I am interested, if there are limitations. Is testing the gui from bash command line any further problem? How is gui-testing done then typically?
Who can help me?
Tia
2.2.1 +macro, bash console, path.append in header: "ImportError"
snippet to head of Testfile:
CODE: SELECT ALL
import sys
sys.path.append("/usr/lib/freecad/lib/")
import FreeCAD as App
import FreeCADGui as Gui

CODE: SELECT ALL
python2.7 /home.../Testpointtopost.py

Traceback (most recent call last):
File "/home/.../Testpointtopost.py", line 21, in <module>
import FemGui
ImportError: Cannot load Gui module in console application.
Solution state:+without Gui
CODE: SELECT ALL
#import FemGui
#import pointtopost
Discussion:
Seems that my unittest does not couple with freecad gui python modules. It the tested module imports a gui module then it comes to this error message running the test. Searched for this error message and found that it is from freecad, placed 3 times here in the forum. The problems with it have not been solved,
So how to deal with it? .. I comment import-lines so I have an either unittest setup with broken gui, or comment it out for otherway arround. This isnot at all confortable: If someone could advice me better, thanks.

Code: Select all

 File "/home/.../Testpointtopost.py", line 21, in <module>
import FemGui
ImportError: Cannot load Gui module in console application.