Coverage for tests/setup_test_env.py: 0%
16 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-16 16:12 -0700
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-16 16:12 -0700
1#!/usr/bin/env python
2"""
3Setup script to create a minimal test environment for copick-torch tests.
5This script is optional and only needed if you want to generate mock data
6for testing without requiring real data.
7"""
9import json
10import os
11from pathlib import Path
13import numpy as np
16def setup_test_env():
17 """
18 Create a minimal test environment for running tests.
20 This includes:
21 1. A mock config file
22 2. A directory structure for mock data
23 """
24 # Create test directory
25 test_dir = Path(__file__).parent / "test_data"
26 test_dir.mkdir(exist_ok=True)
28 # Create overlay directory
29 overlay_dir = test_dir / "overlay"
30 overlay_dir.mkdir(exist_ok=True)
32 # Create a mock config file
33 config = {
34 "config_type": "local",
35 "name": "Test Data",
36 "description": "Mock data for testing",
37 "version": "1.0.0",
38 "pickable_objects": [
39 {
40 "name": "test_object_1",
41 "go_id": "GO:0000001",
42 "is_particle": True,
43 "label": 1,
44 "color": [0, 117, 220, 128],
45 "radius": 30,
46 },
47 {
48 "name": "test_object_2",
49 "go_id": "GO:0000002",
50 "is_particle": True,
51 "label": 2,
52 "color": [153, 63, 0, 128],
53 "radius": 40,
54 },
55 ],
56 "overlay_root": str(overlay_dir),
57 "overlay_fs_args": {"auto_mkdir": True},
58 }
60 config_path = test_dir / "test_config.json"
61 with open(config_path, "w") as f:
62 json.dump(config, f, indent=2)
64 print(f"Created test environment at {test_dir}")
65 print("Set environment variable to use in tests:")
66 print(f"export COPICK_TEST_CONFIG={config_path}")
69if __name__ == "__main__":
70 setup_test_env()