GispoCoding / pytest-qgis

A pytest plugin for testing QGIS python plugins
GNU General Public License v2.0
29 stars 8 forks source link

Windows support #20

Open jmkerloch opened 2 years ago

jmkerloch commented 2 years ago

Expected behaviour I would like to use pytest-qgis in Windows environnement

Current behaviour I tried to launch a test with pytest-qgis use but the module can't be initialized

File "C:\Users\jmker\AppData\Local\Programs\Python\Python39\lib\site-packages\_pytest\assertion\rewrite.py", line 171, in exec_module
    exec(co, module.__dict__)
  File "C:\Users\jmker\AppData\Local\Programs\Python\Python39\lib\site-packages\pytest_qgis\__init__.py", line 21, in <module>
    from pytest_qgis.pytest_qgis import *  # noqa
  File "C:\Users\jmker\AppData\Local\Programs\Python\Python39\lib\site-packages\_pytest\assertion\rewrite.py", line 171, in exec_module
    exec(co, module.__dict__)
  File "C:\Users\jmker\AppData\Local\Programs\Python\Python39\lib\site-packages\pytest_qgis\pytest_qgis.py", line 34, in <module>
    from qgis.core import Qgis, QgsApplication, QgsProject, QgsRectangle, QgsVectorLayer
  File "C:\PROGRA~1\QGIS32~1.1\apps\qgis\python\qgis\core\__init__.py", line 25, in <module>
    from qgis._core import *
ImportError: DLL load failed while importing _core: La procédure spécifiée est introuvable.

My PYTHONPATH and PATH are defined for Qgis use

echo %PYTHONPATH%
C:\PROGRA~1\QGIS32~1.1\apps\qgis\python

echo %PATH%
C:\PROGRA~1\QGIS32~1.1\bin;C:\PROGRA~1\QGIS32~1.1\apps\qgis\bin;C:\Users\jmker\AppData\Local\Programs\Python\Python39;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\CMake\bin;C:\Users\jmker\AppData\Local\Programs\Microsoft VS Code\bin;

Describe alternatives you've considered I did try a manual import in a python console and I managed to import Qgis modules

python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from qgis.core import Qgis, QgsApplication, QgsProject, QgsRectangle, QgsVectorLayer
>>>

Additional context Os : Windows 10 pytest-qgis : 1.3.0

Joonalai commented 2 years ago

Thank you for the issue! We haven't been able to reproduce this issue on Windows yet, but we are trying to get this reproduced at some point.