1+ """
2+ conftest.py
3+ ===========
4+ Pytest configuration and shared fixtures.
5+ Place this in tests/ directory.
6+ """
7+
8+ import pytest
9+ import sys
10+ from pathlib import Path
11+
12+ # Add src to path for imports
13+ src_path = Path (__file__ ).parent .parent / "src"
14+ sys .path .insert (0 , str (src_path ))
15+
16+
17+ def pytest_configure (config ):
18+ """Configure pytest with custom markers."""
19+ config .addinivalue_line (
20+ "markers" , "slow: marks tests as slow (deselect with '-m \" not slow\" ')"
21+ )
22+ config .addinivalue_line (
23+ "markers" , "integration: marks tests as integration tests"
24+ )
25+
26+
27+ def pytest_addoption (parser ):
28+ """Add custom command line options."""
29+ parser .addoption (
30+ "--run-slow" ,
31+ action = "store_true" ,
32+ default = False ,
33+ help = "run slow tests"
34+ )
35+
36+
37+ def pytest_collection_modifyitems (config , items ):
38+ """Skip slow tests unless --run-slow is given."""
39+ if config .getoption ("--run-slow" ):
40+ return
41+
42+ skip_slow = pytest .mark .skip (reason = "need --run-slow option to run" )
43+ for item in items :
44+ if "slow" in item .keywords :
45+ item .add_marker (skip_slow )
46+
47+
48+ @pytest .fixture (scope = "session" )
49+ def test_data_dir ():
50+ """Path to test data directory."""
51+ return Path (__file__ ).parent / "test_data"
52+
53+
54+ @pytest .fixture (scope = "session" , autouse = True )
55+ def setup_test_environment ():
56+ """Setup global test environment."""
57+ # Suppress matplotlib GUI warnings
58+ import matplotlib
59+ matplotlib .use ('Agg' )
60+
61+ # Set random seeds for reproducibility
62+ import random
63+ import numpy as np
64+ random .seed (42 )
65+ np .random .seed (42 )
66+
67+ yield
68+
69+ # Cleanup after all tests
70+ pass
0 commit comments