Skip to content

tests: skip QGIS plugin tests when PyQt6 is unavailable#100

Merged
giswqs merged 3 commits into
opengeos:mainfrom
WoodCedar:tests/skip-qgis-tests-without-pyqt6
May 13, 2026
Merged

tests: skip QGIS plugin tests when PyQt6 is unavailable#100
giswqs merged 3 commits into
opengeos:mainfrom
WoodCedar:tests/skip-qgis-tests-without-pyqt6

Conversation

@WoodCedar

Copy link
Copy Markdown
Contributor

Summary

  • Avoid importing PyQt-backed QGIS plugin tests when PyQt6 is not installed.
  • Add a small dependency sentinel so pytest qgis_geoagent/tests reports a clear skip instead of failing collection or returning no collected tests.
  • Keep the existing strict QGIS/PyQt shim behavior unchanged when PyQt6 is available.

Checks

  • python -m pytest tests -q -> 306 passed, 2 skipped
  • python -m pytest qgis_geoagent/tests -q -> 1 skipped
  • python -m pytest -q -> 306 passed, 3 skipped
  • python -m ruff check qgis_geoagent/tests/conftest.py qgis_geoagent/tests/test_pyqt6_dependency.py
  • python -m pre_commit run --files qgis_geoagent/tests/conftest.py qgis_geoagent/tests/test_pyqt6_dependency.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7e93eac58

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +8 to +10
PyQtCore = import_module("PyQt6.QtCore")
except ImportError:
PyQtCore = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate all required PyQt6 modules in sentinel

conftest.py skips collecting plugin tests when any of PyQt6.QtCore/QtGui/QtNetwork/QtWidgets fails to import, but this sentinel only checks QtCore. In environments where QtCore imports but another required submodule is missing/broken, pytest qgis_geoagent/tests will report a passing sentinel while silently skipping the actual plugin tests, which can hide a real dependency gap.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the qgis_geoagent plugin test suite so environments without PyQt6 don’t fail during collection; instead, pytest will collect a small “dependency sentinel” test that cleanly skips, while PyQt6-enabled environments keep the existing strict QGIS/PyQt shim behavior.

Changes:

  • Added a new sentinel test that skips when PyQt6 is unavailable to ensure pytest qgis_geoagent/tests reports an explicit skip.
  • Updated qgis_geoagent/tests/conftest.py to avoid importing PyQt-backed plugin test modules when PyQt6 imports fail, preventing collection-time failures.
  • Made installation of the QGIS stub conditional on PyQt6 availability.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
qgis_geoagent/tests/test_pyqt6_dependency.py Adds a sentinel test to produce a clear skip when PyQt6 is missing.
qgis_geoagent/tests/conftest.py Switches to conditional PyQt6 imports and ignores collecting plugin tests when PyQt6 is unavailable; only installs QGIS stub when PyQt6 is present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread qgis_geoagent/tests/test_pyqt6_dependency.py
giswqs and others added 2 commits May 13, 2026 11:49
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@giswqs giswqs merged commit a8aaa82 into opengeos:main May 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants