From de587648f88378092ae4e27901f4c8da5cbc95f6 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 9 Apr 2025 18:54:57 +0200 Subject: [PATCH] chore(clan/pytest): discover all test files in the tree --- checks/impure/flake-module.nix | 2 +- .../{tests/test_machine.py => machines/machines_test.py} | 3 ++- pkgs/clan-cli/default.nix | 2 +- pkgs/clan-cli/pyproject.toml | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) rename pkgs/clan-cli/clan_cli/{tests/test_machine.py => machines/machines_test.py} (96%) diff --git a/checks/impure/flake-module.nix b/checks/impure/flake-module.nix index d8cb4752f..93609cbae 100644 --- a/checks/impure/flake-module.nix +++ b/checks/impure/flake-module.nix @@ -30,7 +30,7 @@ # this disables dynamic dependency loading in clan-cli export CLAN_NO_DYNAMIC_DEPS=1 - nix develop "$ROOT#clan-cli" -c bash -c "TMPDIR=/tmp python -m pytest -m impure ./clan_cli/tests $@" + nix develop "$ROOT#clan-cli" -c bash -c "TMPDIR=/tmp python -m pytest -m impure ./clan_cli $@" ''; }; } diff --git a/pkgs/clan-cli/clan_cli/tests/test_machine.py b/pkgs/clan-cli/clan_cli/machines/machines_test.py similarity index 96% rename from pkgs/clan-cli/clan_cli/tests/test_machine.py rename to pkgs/clan-cli/clan_cli/machines/machines_test.py index 6ed0928e1..16e840bd5 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_machine.py +++ b/pkgs/clan-cli/clan_cli/machines/machines_test.py @@ -1,4 +1,5 @@ import pytest + from clan_cli.flake import Flake from clan_cli.machines.machines import Machine @@ -24,7 +25,7 @@ from clan_cli.tests.fixtures_flakes import FlakeForTest indirect=True, ) @pytest.mark.with_core -def test_inventory_deserialize_variants( +def test_inventory_machine_detect_class( test_flake_with_core: FlakeForTest, ) -> None: """ diff --git a/pkgs/clan-cli/default.nix b/pkgs/clan-cli/default.nix index 592cb61ef..e44f90d3d 100644 --- a/pkgs/clan-cli/default.nix +++ b/pkgs/clan-cli/default.nix @@ -212,7 +212,7 @@ pythonRuntime.pkgs.buildPythonApplication { # limit build cores to 16 jobs="$((NIX_BUILD_CORES>16 ? 16 : NIX_BUILD_CORES))" - python -m pytest -m "not impure and with_core" ./clan_cli/tests -n $jobs + python -m pytest -m "not impure and with_core" ./clan_cli -n $jobs touch $out ''; }; diff --git a/pkgs/clan-cli/pyproject.toml b/pkgs/clan-cli/pyproject.toml index 969f91a40..8e6492587 100644 --- a/pkgs/clan-cli/pyproject.toml +++ b/pkgs/clan-cli/pyproject.toml @@ -41,6 +41,7 @@ norecursedirs = ["clan_cli/tests/helpers", "clan_cli/nixpkgs"] # and can be cached more effectively. markers = ["impure", "with_core"] filterwarnings = "default::ResourceWarning" +python_files = ["test_*.py", "*_test.py"] [tool.mypy] python_version = "3.12"