Skip to content

Instantly share code, notes, and snippets.

@Gustry
Created March 18, 2020 08:21
Show Gist options
  • Save Gustry/cb8e67581bf66500254a5df5fa9e8f60 to your computer and use it in GitHub Desktop.
Save Gustry/cb8e67581bf66500254a5df5fa9e8f60 to your computer and use it in GitHub Desktop.
import sys
from qgis.core import QgsVectorLayer, QgsProject
from qgis.testing import unittest, start_app
start_app()
class TestTest(unittest.TestCase):
def test_passes(self):
layer = QgsVectorLayer('Point', 'layer', 'memory')
self.assertTrue(True)
self.assertTrue(layer.isValid())
QgsProject.instance().addMapLayer(layer)
self.assertFalse(False)
def run_all():
"""Default function that is called by the runner if nothing else is specified"""
suite = unittest.TestSuite()
suite.addTests(unittest.makeSuite(TestTest, 'test'))
unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(suite)
@Gustry
Copy link
Author

Gustry commented Mar 18, 2020

Launch this file using docker

  • Use qgis/qgis:latest or qgis/qgis:release-3_4

docker run -d --name qgis -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/etienne/dev/python/test_project/:/tests_directory -e DISPLAY=:99 qgis/qgis:latest

docker exec -it qgis sh -c "cd /tests_directory && qgis_testrunner.sh test_project.run_all"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment