Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest-qgis Compatibility Issue with pytest>=8.0.0 - AssertionError in pytest_addoption #68

Open
zacdezgeo opened this issue Jan 3, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@zacdezgeo
Copy link

zacdezgeo commented Jan 3, 2025

Hey! I came across your project while testing the https://github.com/gee-community/qgis-earthengine-plugin. It's really helpful, and I got things working with pytest==7.4.3. I wanted to raise the error I got with pytest>=8.

Description:

When using pytest-qgis 2.1.0 with pytest 8.x.x, running tests results in the following error:

Traceback (most recent call last):
  File "/path-to-site-packages/pytest_qgis/pytest_qgis.py", line 120, in pytest_addoption
    parser.addini(
  File "/path-to-site-packages/_pytest/config/argparsing.py", line 178, in addini
    assert type in (None, "pathlist", "args", "linelist", "bool")
AssertionError

The error occurs because pytest-qgis is attempting to register an unsupported type when using the parser.addini() method. This appears to be incompatible with stricter validation rules introduced in pytest>=8.0.0.


Expected Behavior:

pytest-qgis should register options with valid types supported by pytest>=8.0.0 without throwing an AssertionError.


Potential Fix?

Update the pytest-qgis source code to define the parser.addini() types as valid values (e.g., "args", "linelist"). Example:

parser.addini("qgis_plugins", type="args", help="QGIS plugin paths")

This change would ensure compatibility with pytest>=8.0.0.


Environment Details:

  • OS: macOS 13.5
  • Python Version: 3.9.5
  • pytest Version: 8.3.4
  • pytest-qgis Version: 2.1.0
  • QGIS Version: 3.28 LTR
@zacdezgeo zacdezgeo added the bug Something isn't working label Jan 3, 2025
@Joonalai
Copy link
Contributor

Joonalai commented Mar 8, 2025

Thank you for the issue and apologies for the late reply. I cannot reproduce the error and by observing pytest source code, string and bool are still valid types. I tried to search from the file history if some values were dropped at some point, but I could not found any. Is this error still happening with newest pytest==8.3.5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants