GispoCoding / pytest-qgis

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

Use tempfile instead of protected TempPathFactory in QGIS config path creation #34

Closed Joonalai closed 1 year ago

Joonalai commented 1 year ago

When using pytest-qgis with pytest-xdist plugin on Windows, the following errors occur:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\?\\C:\\Users\\foo\\AppData\\Local\\Temp\\pytest-of-foo\\pytest-177\\popen-gw0\\qgis-test0\
\profiles\\default\\qgis-auth.db'

This is caused by creating temporary path for QGIS using pytest's internal TempPathFactory, which is not ment to be used by the plugins or in hooks...

This PR suggests a change to use tempfile module instead of TempPathFactory in QGIS config path creation. This is to allow using pytest-xdist plugin to run tests in parallel. In addition plugin pytest-rerunfailures can be used to rerun tests failing randomly with segmentation faults.

This PR also adds a mention about importing modules in conftest to resolve #35.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 66.66% and project coverage change: -0.02 :warning:

Comparison is base (bc9adc6) 54.68% compared to head (86dec5c) 54.66%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #34 +/- ## ========================================== - Coverage 54.68% 54.66% -0.02% ========================================== Files 7 7 Lines 470 472 +2 ========================================== + Hits 257 258 +1 - Misses 213 214 +1 ``` | Flag | Coverage Δ | | |---|---|---| | pytest | `54.66% <66.66%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GispoCoding#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/GispoCoding/pytest-qgis/pull/34?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GispoCoding) | Coverage Δ | | |---|---|---| | [src/pytest\_qgis/pytest\_qgis.py](https://app.codecov.io/gh/GispoCoding/pytest-qgis/pull/34?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GispoCoding#diff-c3JjL3B5dGVzdF9xZ2lzL3B5dGVzdF9xZ2lzLnB5) | `52.67% <66.66%> (-0.03%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.