Skip to content

Commit

Permalink
fix: suppress errors when deleting temp dir [GispoCoding#41]
Browse files Browse the repository at this point in the history
  • Loading branch information
Joonalai committed Jun 26, 2023
1 parent d81a06d commit bcbd449
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions src/pytest_qgis/pytest_qgis.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.


import contextlib
import os.path
import shutil
import sys
Expand Down Expand Up @@ -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 <https://www.gnu.org/licenses/>.


if TYPE_CHECKING:
from _pytest.config import Config
from _pytest.config.argparsing import Parser
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit bcbd449

Please sign in to comment.