Skip to main content

pytest-qfield-e2e

Run plugin and end-to-end tests against a real QField app. Where pytest-qfield renders plugin QML on QGIS with stubs, this plugin starts the stock QField release AppImage through qfield-driver and drives it like a user: real taps, real typing, real forms, real projects. The cloud extra adds a local QFieldCloud for end-to-end tests with several devices syncing through it.

Status: experimental. Linux x64 only. The system requirements are those of qfield-driver.

Fixtures

Fixture Scope What
qfield_app_version session Release under test, from --qfield-version, env QFIELD_VERSION, ini qfield_version, default 4.2.9. latest resolves the newest release.
qfield_app_binary session QField of your own from --qfield-app-binary, env QFIELD_APP_BINARY or ini qfield_app_binary: an AppRun, an AppImage (runs through FUSE) or a build. Otherwise the extracted AppRun, fetched once by qfield-fetch into ~/.cache/qfield-fetch (env QFIELD_FETCH_CACHE_DIR, ini qfield_fetch_cache_dir).
qfield_app_plugins function App plugins installed in every started app, {uuid: directory}. Empty by default.
qfield_app_settings function QField settings written before start, {"myplugin/interval": 50}. For values a plugin reads once on load.
qfield_app_factory function start(name="device", app_plugins=None) starts another app with its own profile.
qfield_app function One running app, a qfield_driver.app.QFieldApp.

With the cloud extra (pytest-qfield-e2e[cloud]):

Fixture Scope What
qfieldcloud_ref session QFieldCloud release: hosted (default), latest or a tag. --qfieldcloud-ref, env QFIELDCLOUD_REF, ini qfieldcloud_ref. With a checkout of your own (--qfieldcloud-source-dir, env QFIELDCLOUD_SOURCE_DIR, ini qfieldcloud_source_dir) it is local-<directory>, and the stack writes its .env.<project> and compose overrides into that checkout.
qfieldcloud_stack session The official compose stack at that release, built and started once, then reused across sessions. --qfieldcloud-down removes it after the session. Ini qfieldcloud_https_port changes its HTTPS port. Ini qfieldcloud_port_offset or env QFIELDCLOUD_PORT_OFFSET (env wins) moves every port up by that offset and suffixes the compose project, see below. qfieldcloud_https_port overrides only the HTTPS port, after the offset.
qfieldcloud_admin session REST client logged in as the admin.
qfieldcloud_user session user(name, password=...) creates a user once and returns its client.
qfieldcloud_project function create(directory, name=None, collaborators=()) uploads and packages a project, deleted after the test.
qfieldcloud_device function start(project_id, username, ...) starts QField, logs in, downloads and opens the project.

Writing tests

from qfield_driver import actions


def test_button_logs(qfield_app, tmp_path):
    qfield_app.host_plugin(PLUGIN_DIR / "main.qml")
    actions.open_project(qfield_app, PROJECT_FILE)

    actions.tap_object(qfield_app, "pluginButton")

    actions.wait_for_message(qfield_app, "Plugin button clicked!")
    assert qfield_app.eval("return plugin.clicks") == 1

qfield_app.eval, host_plugin, the actions helpers and positioning are documented in qfield-driver. qfield_app_plugins installs the plugin under test as a real app plugin instead, a black box.

QFieldCloud recipe

def test_edit_reaches_cloud(
    project_dir,
    qfieldcloud_user,
    qfieldcloud_project,
    qfieldcloud_device,
    qfieldcloud_admin,
):
    qfieldcloud_user("surveyor")
    project_id = qfieldcloud_project(project_dir, collaborators=("surveyor",))
    app = qfieldcloud_device(project_id, "surveyor")

    actions.edit_in_form(app, "points", "fid = 1", "text_field", "new")
    pushed = actions.push(app, project_id)

    deltas = qfieldcloud_admin.wait_for_deltas(project_id, pushed)
    assert {d["status"] for d in deltas} == {"STATUS_APPLIED"}

How the stack runs, and qfield-driver-cloud to start or remove it ahead of a run, are in qfield-driver.

Running

pytest -p no:pytest-qfield -p no:pytest_qgis -p no:pytest-qt test_app

The QGIS based plugins are not needed for app tests and importing Qt in the test process is pointless, so disable them for app test runs.

Each test starts its own QField, about 5 s on a laptop. Device logs are in tmp_path/<device>.log, and qfield_app.screenshot(path) saves the window.

A failing test gets a section per device in its report: the newest message log lines, the log tail and a screenshot path. No screenshot is taken while a camera view is open.

GitHub Actions

The setup-qfield-e2e action installs Xvfb and the AppImage's system libraries on an Ubuntu runner, sets up uv and caches the AppImages between runs. Input python-version picks the Python for uv. The job's token is exported as GITHUB_TOKEN (input github-token) so resolving latest is not rate limited. Pin the action to a commit SHA.

jobs:
  test:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v6
      - uses: Joonalai/qfield-dev-tools/.github/actions/setup-qfield-e2e@<sha>
        with:
          qfield-version: 4.2.9
      - run: uv run pytest

Run it on the runner itself, not in a container: the QFieldCloud fixtures start the stack with the runner's docker.

Faster runs

  • --qfield-app-reuse (ini qfield_app_reuse = true) keeps each device running and resets it between tests: plugin unhosted, popups closed, project cleared, position lost, state emptied. A device is started again when the plugins or settings differ. Settings a test changes stay, so keep it off for tests that rely on a fresh profile. Reused devices log to the session's qfield-devices temporary directory instead of tmp_path.
  • pytest-xdist works, every device has its own display and ports. Workers share one QFieldCloud stack and get their own users, alice becomes alice_gw1 through worker_username, which the cloud fixtures apply. --qfieldcloud-down removes the stack once all workers are done.
  • Several worktrees can run side by side, each with its own stack: give each a distinct QFIELDCLOUD_PORT_OFFSET (or ini qfieldcloud_port_offset), for example 10, which moves all five ports and suffixes the compose project. Runs that share one stack share its one admin token, and one run's login invalidates the other's (Token has expired), so they need distinct offsets. Use multiples of 10 up to 50, other offsets can make host ports collide, see Several stacks at once. Every offset builds its own images, a long first start and extra GB.

Metadata

Release files for pytest-qfield-e2e 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-qfield-e2e 0.2.2
File Size Uploaded Provenance Actions
pytest_qfield_e2e-0.2.2.tar.gz 19.4 kB Without provenance Details for pytest_qfield_e2e-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-qfield-e2e 0.2.2
File Interpreter ABI Platform Actions
pytest_qfield_e2e-0.2.2-py3-none-any.whl Python 3 none any Details for pytest_qfield_e2e-0.2.2-py3-none-any.whl

Total release size: 38.6 kB

Release files / pytest_qfield_e2e-0.2.2.tar.gz

Download URL pytest_qfield_e2e-0.2.2.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a79f34b3d92edb561de1b94adfdfa050b501dbda45d0ec73f8b24ee2fc869b99
BLAKE2b-256 checksum
How to use checksums
d8b07167b115646edf707b3bda6ab71d03c13dcf9fe5a6c1c4cf6b3d0216839d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pytest_qfield_e2e-0.2.2-py3-none-any.whl

Download URL pytest_qfield_e2e-0.2.2-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7411010707af0476ff113cf80f47b47ad01815d99b19cc84d4222d4b03e1db0
BLAKE2b-256 checksum
How to use checksums
234aa35c21565d6d2580958697cf322de5ce8479cd9bcc69f0d693f0789a8640
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pytest-qfield-e2e 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page