[QGIS-Developer] Python plugin Processing tests using QGIS Docker

Joona Laine joona.p.laine at gmail.com
Tue Nov 11 02:05:59 PST 2025


Hi,

Are you using pytest-qgis already in your tests? If you are, just use the
fixture qgis_processing in your tests and testing processing algorithms
should work just fine. Check here for more details on how to easily test
algorithms: https://github.com/GispoCoding/pytest-qgis/issues/27

Cheers,
Joona

ti 11.11.2025 klo 11.09 Sergi Maspons - BGEO via QGIS-Developer (
qgis-developer at lists.osgeo.org) kirjoitti:

> Hi all,
>
> I'm trying to build some CI tests on GitHub (with pytest) using the
> official qgis/qgis Docker image. Everything works fine except for the parts
> of my plugin that use Processing algorithms. I'd like to run full workflow
> tests, but the processing plugin doesn't seem to be available in the
> container.
>
> When I try to load it with qgis.utils.loadPlugin('processing') I get this
> error:
>
> Python error(2): Traceback (most recent call last):  File "/usr/share/qgis/python/qgis/utils.py", line 447, in loadPlugin    __import__(packageName)  File "/usr/share/qgis/python/qgis/utils.py", line 1100, in _import    mod = _builtin_import(name, globals, locals, fromlist, level)          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ModuleNotFoundError: No module named 'processing'
> Couldn't load plugin 'processing'(1): Couldn't load plugin 'processing'
>
> I can't find much documentation on how to build CI tests for a QGIS
> plugin, so I've been trying to make it work, but I don't know if I'm doing
> it rightly...
>
> I've tried installing extra packages (qgis-plugin-grass, grass, saga) in
> the Dockerfile, but it didn't help.
>
> Here's my *Dockerfile*:
>
> ARG QGIS_TEST_VERSION=latest
> FROM  qgis/qgis:${QGIS_TEST_VERSION}
>
> RUN apt-get update \
>     && apt-get install -y python3-pip qgis-plugin-grass grass saga \
>     && rm -rf /var/lib/apt/lists/*
>
> COPY ./test/requirements.txt /tmp/
> RUN pip3 install --upgrade pip || true
> RUN pip3 install -r /tmp/requirements.txt || pip3 install -r /tmp/requirements.txt --break-system-packages
> ENV LANG=C.UTF-8
> WORKDIR /
>
> This is my *run-docker-tests.sh*:
>
> #!/usr/bin/env bash
> set -e
> pushd /usr/src/ibergis_qgis_plugin
> xvfb-run pytest
> popd
>
> And the relevant part of *GitHub Actions (test.yml)*:
>
>   # Run unit tests
>   tests-qgis:
>     runs-on: ubuntu-24.04
>     strategy:
>       fail-fast: false
>       matrix:
>         qgis_version: [latest, ltr, stable]
>     env:
>       QGIS_TEST_VERSION: ${{ matrix.qgis_version }}
>     steps:
>       - name: Checkout
>         uses: actions/checkout at v4
>         with:
>           submodules: recursive
>
>       - name: Test
>         run: |
>           chmod +x .docker/run-docker-tests.sh
>           docker compose -f .docker/docker-compose.yml run qgis /usr/src/ibergis_qgis_plugin/.docker/run-docker-tests.sh
>
> I haven't found much documentation on running QGIS plugin tests in CI
> environments, so I might be missing something obvious.
> If anyone has experience running tests that use Processing algorithms
> inside Docker, I'd really appreciate some guidance.
>
> Thanks in advance!
> --
> *Sergi Maspons "Maspi"*
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20251111/0be6e31f/attachment.htm>


More information about the QGIS-Developer mailing list