clan-cli tests: remove dynamic inclusion of helpers module
Dynamically extending the python path at runtime is bad for developer experience, as this is not understood by the text editor and therefore jump to definition etc. does not work. -> Better to remove the dynamic inclusion and force developers to specify the import correctly.
This commit is contained in:
@@ -51,6 +51,9 @@ mkShell {
|
||||
export GIT_ROOT=$(git rev-parse --show-toplevel)
|
||||
export PKG_ROOT=$GIT_ROOT/pkgs/clan-app
|
||||
|
||||
# Add current package to PYTHONPATH
|
||||
export PYTHONPATH="$PKG_ROOT''${PYTHONPATH:+:$PYTHONPATH:}"
|
||||
|
||||
# Add clan-app command to PATH
|
||||
export PATH="$PKG_ROOT/bin":"$PATH"
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from clan_cli.custom_logger import setup_logging
|
||||
from clan_cli.nix import nix_shell
|
||||
|
||||
sys.path.append(str(Path(__file__).parent / "helpers"))
|
||||
sys.path.append(str(Path(__file__).parent.parent)) # Also add clan app to PYTHONPATH
|
||||
|
||||
pytest_plugins = [
|
||||
"temporary_dir",
|
||||
"root",
|
||||
|
||||
0
pkgs/clan-app/tests/helpers/__init__.py
Normal file
0
pkgs/clan-app/tests/helpers/__init__.py
Normal file
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from helpers.cli import Cli
|
||||
|
||||
|
||||
def test_help(capfd: pytest.CaptureFixture) -> None:
|
||||
|
||||
@@ -31,6 +31,9 @@ mkShell {
|
||||
export GIT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
export PKG_ROOT="$GIT_ROOT/pkgs/clan-cli"
|
||||
|
||||
# Add current package to PYTHONPATH
|
||||
export PYTHONPATH="$PKG_ROOT''${PYTHONPATH:+:$PYTHONPATH:}"
|
||||
|
||||
# Add clan command to PATH
|
||||
export PATH="$PKG_ROOT/bin":"$PATH"
|
||||
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "helpers"))
|
||||
sys.path.append(str(Path(__file__).parent.parent)) # Also add clan_cli to PYTHONPATH
|
||||
|
||||
|
||||
from clan_cli.custom_logger import setup_logging
|
||||
from clan_cli.nix import nix_shell
|
||||
|
||||
|
||||
0
pkgs/clan-cli/tests/helpers/__init__.py
Normal file
0
pkgs/clan-cli/tests/helpers/__init__.py
Normal file
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from helpers.cli import Cli
|
||||
|
||||
|
||||
def test_help(capsys: pytest.CaptureFixture) -> None:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
|
||||
from clan_cli import config
|
||||
from clan_cli.config import parsing
|
||||
|
||||
@@ -3,7 +3,7 @@ import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from helpers.cli import Cli
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
@@ -2,8 +2,8 @@ import json
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
from pytest import CaptureFixture
|
||||
|
||||
from clan_cli.dirs import user_history_file
|
||||
|
||||
@@ -2,8 +2,8 @@ from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from age_keys import KeyPair
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
|
||||
@@ -13,7 +13,7 @@ from clan_cli.nix import nix_eval, run_no_stdout
|
||||
if TYPE_CHECKING:
|
||||
from age_keys import KeyPair
|
||||
|
||||
from cli import Cli
|
||||
from helpers.cli import Cli
|
||||
|
||||
from clan_cli.machines.facts import machine_get_fact
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ from contextlib import contextmanager
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
|
||||
from clan_cli.errors import ClanError
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import ipaddress
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from validator import is_valid_age_key, is_valid_ssh_key
|
||||
from helpers.cli import Cli
|
||||
from helpers.validator import is_valid_age_key, is_valid_ssh_key
|
||||
|
||||
from clan_cli.clan_uri import FlakeId
|
||||
from clan_cli.facts.secret_modules.sops import SecretStore
|
||||
|
||||
@@ -2,9 +2,9 @@ import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from validator import is_valid_ssh_key
|
||||
from helpers.cli import Cli
|
||||
from helpers.validator import is_valid_ssh_key
|
||||
|
||||
from clan_cli.clan_uri import FlakeId
|
||||
from clan_cli.facts.secret_modules.password_store import SecretStore
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from helpers.cli import Cli
|
||||
|
||||
from clan_cli.ssh import HostGroup
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ from time import sleep
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest, generate_flake
|
||||
from helpers.cli import Cli
|
||||
from root import CLAN_CORE
|
||||
|
||||
from clan_cli.dirs import vm_state_dir
|
||||
|
||||
Reference in New Issue
Block a user