diff --git a/src/pytest_qgis/pytest_qgis.py b/src/pytest_qgis/pytest_qgis.py
index 4f336e0..c9b0a3d 100644
--- a/src/pytest_qgis/pytest_qgis.py
+++ b/src/pytest_qgis/pytest_qgis.py
@@ -1,24 +1,5 @@
# -*- coding: utf-8 -*-
-
-# Copyright (C) 2021-2023 pytest-qgis Contributors.
-#
-#
-# This file is part of pytest-qgis.
-#
-# pytest-qgis is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# pytest-qgis is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with pytest-qgis. If not, see .
-
-
+import contextlib
import os.path
import shutil
import sys
@@ -49,6 +30,25 @@
set_map_crs_based_on_layers,
)
+# Copyright (C) 2021-2023 pytest-qgis Contributors.
+#
+#
+# This file is part of pytest-qgis.
+#
+# pytest-qgis is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# pytest-qgis is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with pytest-qgis. If not, see .
+
+
if TYPE_CHECKING:
from _pytest.config import Config
from _pytest.config.argparsing import Parser
@@ -155,7 +155,8 @@ def qgis_app(request: "SubRequest") -> QgsApplication:
_CANVAS.deleteLater()
_APP.exitQgis()
if _QGIS_CONFIG_PATH and _QGIS_CONFIG_PATH.exists():
- shutil.rmtree(_QGIS_CONFIG_PATH)
+ with contextlib.suppress(PermissionError):
+ shutil.rmtree(_QGIS_CONFIG_PATH)
@pytest.fixture(scope="session")