From 15b88354217e01972c6c43fd195cefe01f7f09fd Mon Sep 17 00:00:00 2001
From: dcarron <daniel.carron@idiap.ch>
Date: Fri, 28 Jun 2024 11:41:49 +0200
Subject: [PATCH] [tests] Fix paths

---
 tests/classification/test_cli.py | 27 +++++++++++++--------------
 tests/segmentation/test_cli.py   | 14 +++++++-------
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/tests/classification/test_cli.py b/tests/classification/test_cli.py
index 8861da70..c9c7dfd3 100644
--- a/tests/classification/test_cli.py
+++ b/tests/classification/test_cli.py
@@ -195,7 +195,7 @@ def test_train_pasa_montgomery(temporary_basedir):
     runner = CliRunner()
 
     with stdout_logging() as buf:
-        output_folder = temporary_basedir / "results"
+        output_folder = temporary_basedir / "classification" / "results"
         result = runner.invoke(
             train,
             [
@@ -250,7 +250,7 @@ def test_train_pasa_montgomery_from_checkpoint(temporary_basedir):
 
     runner = CliRunner()
 
-    output_folder = temporary_basedir / "results" / "pasa_checkpoint"
+    output_folder = temporary_basedir / "classification" / "results" / "pasa_checkpoint"
     result0 = runner.invoke(
         train,
         [
@@ -329,9 +329,9 @@ def test_predict_pasa_montgomery(temporary_basedir, datadir):
     runner = CliRunner()
 
     with stdout_logging() as buf:
-        output = temporary_basedir / "predictions"
+        output = temporary_basedir / "classification" / "predictions"
         last = _get_checkpoint_from_alias(
-            temporary_basedir / "results",
+            temporary_basedir / "classification" / "results",
             "periodic",
         )
         assert last.name.endswith("epoch=0" + CHECKPOINT_EXTENSION)
@@ -379,27 +379,26 @@ def test_evaluate_pasa_montgomery(temporary_basedir):
     runner = CliRunner()
 
     with stdout_logging() as buf:
-        prediction_path = temporary_basedir / "predictions"
+        prediction_path = temporary_basedir / "classification" / "predictions"
         predictions_file = prediction_path / "predictions.json"
-        evaluation_filename = "evaluation.json"
-        evaluation_file = temporary_basedir / evaluation_filename
+        evaluation_path = temporary_basedir / "classification" / "evaluations"
+
         result = runner.invoke(
             evaluate,
             [
                 "-vv",
                 "montgomery",
                 f"--predictions={predictions_file}",
-                f"--output-folder={temporary_basedir}",
+                f"--output-folder={evaluation_path}",
                 "--threshold=test",
             ],
         )
         _assert_exit_0(result)
 
-        assert evaluation_file.exists()
-        assert evaluation_file.with_suffix(".meta.json").exists()
-        assert evaluation_file.with_suffix(".rst").exists()
-        assert evaluation_file.with_suffix(".pdf").exists()
-
+        assert (evaluation_path / "evaluation.json").exists()
+        assert (evaluation_path / "evaluation.meta.json").exists()
+        assert (evaluation_path / "evaluation.pdf").exists()
+        assert (evaluation_path / "evaluation.rst").exists()
         keywords = {
             r"^Setting --threshold=.*$": 1,
             r"^Analyzing split `train`...$": 1,
@@ -426,7 +425,7 @@ def test_experiment(temporary_basedir):
 
     runner = CliRunner()
 
-    output_folder = temporary_basedir / "experiment"
+    output_folder = temporary_basedir / "classification" / "experiment"
     num_epochs = 2
     result = runner.invoke(
         experiment,
diff --git a/tests/segmentation/test_cli.py b/tests/segmentation/test_cli.py
index 4d6bae66..926556bc 100644
--- a/tests/segmentation/test_cli.py
+++ b/tests/segmentation/test_cli.py
@@ -163,7 +163,7 @@ def test_train_lwnet_drive(temporary_basedir):
     runner = CliRunner()
 
     with stdout_logging() as buf:
-        output_folder = temporary_basedir / "results"
+        output_folder = temporary_basedir / "segmentation" / "results"
         result = runner.invoke(
             train,
             [
@@ -215,7 +215,7 @@ def test_train_lwnet_drive_from_checkpoint(temporary_basedir):
 
     runner = CliRunner()
 
-    output_folder = temporary_basedir / "results" / "lwnet_checkpoint"
+    output_folder = temporary_basedir / "segmentation" / "results" / "lwnet_checkpoint"
     result0 = runner.invoke(
         train,
         [
@@ -291,9 +291,9 @@ def test_predict_lwnet_drive(temporary_basedir, datadir):
     runner = CliRunner()
 
     with stdout_logging() as buf:
-        output = temporary_basedir / "predictions"
+        output = temporary_basedir / "segmentation" / "predictions"
         last = _get_checkpoint_from_alias(
-            temporary_basedir / "results",
+            temporary_basedir / "segmentation" / "results",
             "periodic",
         )
         assert last.name.endswith("epoch=0" + CHECKPOINT_EXTENSION)
@@ -340,9 +340,9 @@ def test_evaluate_lwnet_drive(temporary_basedir):
     runner = CliRunner()
 
     with stdout_logging() as buf:
-        prediction_path = temporary_basedir / "predictions"
+        prediction_path = temporary_basedir / "segmentation" / "predictions"
         predictions_file = prediction_path / "predictions.json"
-        evaluation_path = temporary_basedir / "evaluations"
+        evaluation_path = temporary_basedir / "segmentation" / "evaluations"
         result = runner.invoke(
             evaluate,
             [
@@ -388,7 +388,7 @@ def test_experiment(temporary_basedir):
 
     runner = CliRunner()
 
-    output_folder = temporary_basedir / "experiment"
+    output_folder = temporary_basedir / "segmentation" / "experiment"
     num_epochs = 2
     result = runner.invoke(
         experiment,
-- 
GitLab