diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8c6f95ed0..76c9ea260 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,3 +28,12 @@ repos: rev: v3.2.0 hooks: - id: pyupgrade + - repo: local + hooks: + - id: check_unmarked_tests + name: check_unmarked_tests + entry: devtools/check_unmarked_tests.sh + language: script + files: ^tests/ + types: [python] + pass_filenames: true diff --git a/devtools/check_unmarked_tests.sh b/devtools/check_unmarked_tests.sh new file mode 100755 index 000000000..08371f211 --- /dev/null +++ b/devtools/check_unmarked_tests.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Start the timer using date (in seconds since epoch) +start_time=$(date +%s) + +echo "Files to check: $@" +# Collect unmarked tests for the specific file and suppress errors +unmarked=$(pytest "$@" --collect-only -m "not unit and not regression" -q 2> /dev/null | head -n -2) + +# Count the number of unmarked tests found, ignoring empty lines +num_unmarked=$(echo "$unmarked" | sed '/^\s*$/d' | wc -l) + +# If there are any unmarked tests, print them and exit with status 1 +if [ "$num_unmarked" -gt 0 ]; then + echo "----found unmarked tests----" + echo "$unmarked" + # Calculate the elapsed time and print with a newline + end_time=$(date +%s) + elapsed_time=$((end_time - start_time)) + printf "\nTime taken: %d seconds" "$elapsed_time" + exit 1 +fi diff --git a/tests/baseline/test_fsa_F_normalized.png b/tests/baseline/test_fsa_F_normalized.png index 170263d9e..6a7fdaa3c 100644 Binary files a/tests/baseline/test_fsa_F_normalized.png and b/tests/baseline/test_fsa_F_normalized.png differ diff --git a/tests/test_curves.py b/tests/test_curves.py index 74fd41aa9..0b1af1d63 100644 --- a/tests/test_curves.py +++ b/tests/test_curves.py @@ -262,6 +262,7 @@ def test_from_input_file(self): np.testing.assert_allclose(curve3.NFP, curve4.NFP) np.testing.assert_allclose(curve3.sym, curve4.sym) + @pytest.mark.unit def test_to_FourierRZCurve(self): """Test conversion to FourierRZCurve.""" xyz = FourierXYZCurve(modes=[-1, 1], X_n=[0, 10], Y_n=[10, 0], Z_n=[0, 0]) diff --git a/tests/test_objective_funs.py b/tests/test_objective_funs.py index 289e95b0d..035bd656e 100644 --- a/tests/test_objective_funs.py +++ b/tests/test_objective_funs.py @@ -914,6 +914,7 @@ def test(coil, grid=None): test(mixed_coils) test(nested_coils, grid=grid) + @pytest.mark.unit def test_coil_type_error(self): """Tests error when objective is not passed a coil.""" curve = FourierPlanarCurve(r_n=2, basis="rpz") @@ -1104,6 +1105,7 @@ def test( # TODO: add more complex test case with a stellarator and/or MixedCoilSet + @pytest.mark.unit def test_quadratic_flux(self): """Test calculation of quadratic flux on the boundary.""" t_field = ToroidalMagneticField(1, 1) @@ -2979,6 +2981,7 @@ def test_asymmetric_normalization(): assert np.all(np.isfinite(val)) +@pytest.mark.unit def test_objective_print_widths(): """Test that the objective's name is shorter than max.""" subclasses = _Objective.__subclasses__() @@ -3007,6 +3010,7 @@ def test_objective_print_widths(): ) +@pytest.mark.unit def test_objective_docstring(): """Test that the objective docstring and collect_docs are consistent.""" objective_docs = _Objective.__doc__.rstrip()