I am creating a GUI skeleton (for now) using PyQt5 and I have written some unit tests (using Python's unittest package) for testing its basic features. While trying to automate the procedure of running those unit tests each time a commit is made to this repository (currently hosted in GitLab), I have created the following .gitlab-ci.yml file:
before_script:
- sudo apt-get -qq update && sudo apt-get -qq install -y python3
- sudo apt-get -qq update
- sudo apt-get -qq install -y python3 python-virtualenv python3-pip
- virtualenv venv
- . venv/bin/activate
- sudo apt-get install python3-pyqt5 -y
- sudo apt-get install python3-pyqt5.qtmultimedia -y
- cd test
stages:
- test
job1:
stage: test
script: python3 -m unittest -v test.GuiTest
Which does run (so the runners should have been set up correctly) but I am getting the following error when executing the script of job 1:
$ python3 -m unittest -v test QXcbConnection: Could not connect to display bash: line 62: 50549 Aborted (core dumped) python3 -m unittest -v test ERROR: Job failed: exit status 1
From the research I did, it seems that the CI server is facing problems trying to run a graphical application. However, for running the unit tests, no any actual window needs to be opened. The problem seems to be this particular line of the test (.py) file:
application = QApplication(sys.argv)
Is there any way in which I can bypass this issue? I do understand that if the testing functions required any graphical feature (e.g. pressing a button) this would be a problem but in this case, there is no such need.
Thanks a lot.
EDIT: Could you please have a look at this question since it was probably posted on an incorrect timing.