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. 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(iniqfield_app_reuse = true) keeps each device running and resets it between tests: plugin unhosted, popups closed, project cleared, position lost,stateemptied. 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'sqfield-devicestemporary directory instead oftmp_path.pytest-xdistworks, every device has its own display and ports. Workers share one QFieldCloud stack and get their own users,alicebecomesalice_gw1throughworker_username, which the cloud fixtures apply.--qfieldcloud-downremoves 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 iniqfieldcloud_port_offset), for example10, 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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_qfield_e2e-0.2.1.tar.gz | 19.3 kB | Without provenance | Details for pytest_qfield_e2e-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_qfield_e2e-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for pytest_qfield_e2e-0.2.1-py3-none-any.whl |
Total release size: 38.4 kB
Release files / pytest_qfield_e2e-0.2.1.tar.gz
| Download URL | pytest_qfield_e2e-0.2.1.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15cb47b7598e84a791973b2ab377a2f88fecfa2b1ad73413ba6a881f3f0161b2
|
|
BLAKE2b-256 checksum How to use checksums |
0c6662c0b262ce8bcb23dd3dedf5c3293c4062a0d506602fb86bf66921c3227c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","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.1-py3-none-any.whl
| Download URL | pytest_qfield_e2e-0.2.1-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb2d238876ffdc575acee9fce8c58835129a79ee0a18b0e7894ca611fdc32173
|
|
BLAKE2b-256 checksum How to use checksums |
125210e81447060dbb8092f1d2bdf611aeee83a397a00e9b6496a8a372a97558
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","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.1
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.