Skip to content

Commit 0eb6af8

Browse files
committed
tests should use testing_folder
1 parent a3de54b commit 0eb6af8

28 files changed

Lines changed: 79 additions & 64 deletions

tests/pyptv/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ def clean_test_environment(test_data_dir):
3131
shutil.rmtree(results_dir)
3232

3333

34+
@pytest.fixture
35+
def copy_test_case(test_data_dir, tmp_path):
36+
"""Copy one named test case from the shared fixture tree into a temp directory."""
37+
38+
def _copy(case_name: str):
39+
source = test_data_dir / case_name
40+
if not source.exists():
41+
pytest.skip(f"Test case directory {source} not found")
42+
43+
destination = tmp_path / case_name
44+
shutil.copytree(source, destination, dirs_exist_ok=True)
45+
return destination
46+
47+
return _copy
48+
49+
3450
def pytest_runtest_setup(item):
3551
if 'qt' in item.keywords:
3652
try:

tests/pyptv/test_apply_optimizations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
from pathlib import Path
1212

1313

14-
def apply_optimized_parameters():
14+
def apply_optimized_parameters(copy_test_case):
1515
"""Apply the optimized tracking parameters found through testing"""
1616

17-
test_path = Path(__file__).parent.parent / "working_folder" / "test_splitter"
17+
test_path = copy_test_case("test_splitter")
1818
yaml_file = test_path / "parameters_Run1.yaml"
1919

2020
if not yaml_file.exists():
@@ -54,12 +54,12 @@ def apply_optimized_parameters():
5454
return True
5555

5656

57-
def test_optimized_performance():
57+
def test_optimized_performance(copy_test_case):
5858
"""Test tracking performance with optimized parameters"""
5959

6060
import subprocess
6161

62-
test_path = Path(__file__).parent.parent / "working_folder" / "test_splitter"
62+
test_path = copy_test_case("test_splitter")
6363
yaml_file = test_path / "parameters_Run1.yaml"
6464
script_path = Path(__file__).parent.parent / "pyptv" / "pyptv_batch_plugins.py"
6565
cmd = [

tests/pyptv/test_cal_ori_roundtrip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from pyptv.parameter_manager import ParameterManager
66

77
@pytest.mark.parametrize("src_dir", [
8-
"tests/working_folder/test_cavity/parameters",
9-
"tests/working_folder/test_splitter/parameters",
8+
"tests/testing_folder/test_cavity/parameters",
9+
"tests/testing_folder/test_splitter/parameters (copy)",
1010
])
1111
def test_cal_ori_roundtrip(src_dir, tmp_path):
1212
work_dir = tmp_path / "par_files"

tests/pyptv/test_cavity_comprehensive.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44
from pathlib import Path
55
import numpy as np
6+
import shutil
67

78
from pyptv.parameter_manager import ParameterManager
89

@@ -17,10 +18,10 @@
1718

1819

1920
@pytest.fixture
20-
def test_cavity_setup():
21+
def test_cavity_setup(copy_test_case):
2122
"""Setup fixture for test_cavity experiment"""
2223
software_path = Path(__file__).parent.parent
23-
test_cavity_path = software_path / "working_folder" / "test_cavity"
24+
test_cavity_path = copy_test_case("test_cavity")
2425

2526
if not test_cavity_path.exists():
2627
pytest.skip(f"Test cavity directory does not exist: {test_cavity_path}")
@@ -51,10 +52,9 @@ def test_cavity_setup():
5152
os.chdir(original_cwd)
5253

5354

54-
def test_cavity_directory_structure():
55+
def test_cavity_directory_structure(copy_test_case):
5556
"""Test that test_cavity directory has expected structure"""
56-
software_path = Path(__file__).parent.parent
57-
test_cavity_path = software_path / "working_folder" / "test_cavity"
57+
test_cavity_path = copy_test_case("test_cavity")
5858

5959
assert test_cavity_path.exists(), f"Test cavity directory does not exist: {test_cavity_path}"
6060

tests/pyptv/test_core_functionality.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@pytest.fixture
1010
def test_cavity_dir():
1111
# Fixture to provide the test_cavity directory path
12-
return os.path.join(os.path.dirname(__file__), "..", "working_folder", "test_cavity")
12+
return os.path.join(os.path.dirname(__file__), "..", "testing_folder", "test_cavity")
1313

1414
def test_core_functionality(test_cavity_dir, capsys):
1515
"""Test core functionality of pyptv and optv"""

tests/pyptv/test_detection_bug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_detection_parameters_bug():
2020
"""Test that reproduces the detection parameters bug."""
2121

2222
# Load test parameters
23-
test_dir = Path("tests/working_folder/test_cavity")
23+
test_dir = Path("tests/testing_folder/test_cavity")
2424
yaml_file = test_dir / "parameters_Run1.yaml"
2525

2626
experiment = Experiment()

tests/pyptv/test_detection_consistency.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TestDetectionConsistency:
2020
def experiment(self):
2121
"""Create an experiment with test cavity parameters."""
2222
experiment = Experiment()
23-
test_dir = Path(__file__).parent.parent / "working_folder" / "test_cavity"
23+
test_dir = Path(__file__).parent.parent / "testing_folder" / "test_cavity"
2424
experiment.populate_runs(test_dir)
2525
experiment.set_active(0) # Use first parameter set
2626
return experiment
@@ -118,7 +118,7 @@ def test_parameter_sections_exist(self, experiment):
118118

119119
from pyptv.experiment import Experiment
120120
experiment = Experiment()
121-
test_dir = Path(__file__).parent.parent / "working_folder" / "test_cavity"
121+
test_dir = Path(__file__).parent.parent / "testing_folder" / "test_cavity"
122122
experiment.populate_runs(test_dir)
123123
experiment.set_active(0)
124124

tests/pyptv/test_experiment_par_to_yaml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pyptv.parameter_manager import ParameterManager
44
import yaml
55

6-
TRACK_DIR = Path(__file__).parent.parent / "working_folder" / "test_cavity"
6+
TRACK_DIR = Path(__file__).parent.parent / "testing_folder" / "test_cavity"
77

88
@pytest.mark.parametrize("param_dir,param_yaml", [
99
("parameters", "parameters_Run1.yaml"),

tests/pyptv/test_ext_sequence_splitter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_ext_sequence_splitter():
99
"""Test the ext_sequence_splitter plugin using batch command (proven working approach)"""
1010

1111
# Path to the test data (in tests/ directory)
12-
test_path = Path(__file__).parent.parent / "working_folder" / "test_splitter"
12+
test_path = copy_test_case("test_splitter")
1313

1414
if not test_path.exists():
1515
print(f"❌ Test data not found: {test_path}")
@@ -89,7 +89,7 @@ def test_batch_command():
8989

9090
# Fix paths for running from tests/ directory
9191
script_path = Path(__file__).parent.parent / "pyptv" / "pyptv_batch_plugins.py"
92-
test_exp_path = Path(__file__).parent.parent / "working_folder" / "test_splitter"
92+
test_exp_path = copy_test_case("test_splitter")
9393

9494
if not script_path.exists():
9595
print(f"❌ Batch script not found: {script_path}")

tests/pyptv/test_ext_sequence_splitter_pytest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from pyptv.pyptv_batch_plugins import run_batch
77

88
@pytest.mark.integration
9-
def test_ext_sequence_splitter_plugin():
9+
def test_ext_sequence_splitter_plugin(copy_test_case):
1010
"""Test that ext_sequence_splitter plugin runs without errors using direct call."""
11-
test_exp_path = Path(__file__).parent.parent / "working_folder" / "test_splitter"
11+
test_exp_path = copy_test_case("test_splitter")
1212
yaml_file = test_exp_path / "parameters_Run1.yaml"
1313
assert yaml_file.exists(), f"YAML file not found: {yaml_file}"
1414

0 commit comments

Comments
 (0)