summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Finkler <3929834+DudeNr33@users.noreply.github.com>2023-04-02 16:32:32 +0200
committerGitHub <noreply@github.com>2023-04-02 16:32:32 +0200
commit0ec3c7f36630610c0002ef9d69c4885daf80b0ea (patch)
tree25c7818fd778f3b842598769d987dc16e3a44a74
parent6ad17fb758361f50210f4cb5a4fd34494034f4e0 (diff)
downloadpylint-git-0ec3c7f36630610c0002ef9d69c4885daf80b0ea.tar.gz
refactor pyreverse tests to use temporary directory (#8529)
-rw-r--r--tests/pyreverse/test_writer.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/tests/pyreverse/test_writer.py b/tests/pyreverse/test_writer.py
index 72f643c4a..ed0f5b31e 100644
--- a/tests/pyreverse/test_writer.py
+++ b/tests/pyreverse/test_writer.py
@@ -10,9 +10,11 @@ import codecs
import os
from collections.abc import Iterator
from difflib import unified_diff
+from pathlib import Path
from unittest.mock import Mock
import pytest
+from pytest import MonkeyPatch
from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
from pylint.pyreverse.inspector import Linker, Project
@@ -71,6 +73,11 @@ def _file_lines(path: str) -> list[str]:
return [line for line in lines if line]
+@pytest.fixture(autouse=True)
+def change_to_temp_dir(monkeypatch: MonkeyPatch, tmp_path: Path) -> None:
+ monkeypatch.chdir(tmp_path)
+
+
@pytest.fixture()
def setup_dot(
default_config: PyreverseConfig, get_project: GetProjectCallable
@@ -146,19 +153,6 @@ def _setup(
diagram.extract_relationships()
writer.write(dd)
yield
- for fname in (
- DOT_FILES
- + COLORIZED_DOT_FILES
- + NO_STANDALONE_FILES
- + PUML_FILES
- + COLORIZED_PUML_FILES
- + MMD_FILES
- + HTML_FILES
- ):
- try:
- os.remove(fname)
- except FileNotFoundError:
- continue
@pytest.mark.usefixtures("setup_dot")
@@ -240,5 +234,3 @@ def test_package_name_with_slash(default_config: PyreverseConfig) -> None:
writer.write([obj])
assert os.path.exists("test_package_name_with_slash_.dot")
- # remove the generated file
- os.remove("test_package_name_with_slash_.dot")