From 29c711db3046c51e84e874a40d5fb7674f680770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 28 Jul 2023 12:48:59 +0200 Subject: [PATCH] add clan_flake fixture to setup a temporary clan --- pkgs/clan-cli/tests/clan_flake.py | 17 +++++++++++++++++ pkgs/clan-cli/tests/conftest.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 pkgs/clan-cli/tests/clan_flake.py diff --git a/pkgs/clan-cli/tests/clan_flake.py b/pkgs/clan-cli/tests/clan_flake.py new file mode 100644 index 000000000..5a71635a8 --- /dev/null +++ b/pkgs/clan-cli/tests/clan_flake.py @@ -0,0 +1,17 @@ +from pathlib import Path +from typing import Iterator + +import pytest +from environment import mock_env + + +@pytest.fixture +def clan_flake( + temporary_directory: Path, monkeypatch: pytest.MonkeyPatch +) -> Iterator[Path]: + flake = temporary_directory / "clan-flake" + flake.mkdir() + (flake / ".clan-flake").touch() + monkeypatch.chdir(flake) + with mock_env(HOME=str(temporary_directory)): + yield temporary_directory diff --git a/pkgs/clan-cli/tests/conftest.py b/pkgs/clan-cli/tests/conftest.py index f9b5b00d3..14a0cf031 100644 --- a/pkgs/clan-cli/tests/conftest.py +++ b/pkgs/clan-cli/tests/conftest.py @@ -3,4 +3,4 @@ import sys sys.path.append(os.path.join(os.path.dirname(__file__), "helpers")) -pytest_plugins = ["temporary_dir"] +pytest_plugins = ["temporary_dir", "clan_flake"]