Skip to content

Commit f44ce12

Browse files
Upload test script.
1 parent 25cf3e7 commit f44ce12

5 files changed

Lines changed: 762 additions & 2 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
tests/
21
.venv
32
pytest.ini
4-
requirements-test.txt
53
examples
64
__pycache__
75
.pytest_cache

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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

tests/requirements-test.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Testing dependencies
2+
pytest==7.4.3
3+
pytest-cov==4.1.0
4+
pytest-xdist==3.5.0 # for parallel test execution
5+
pytest-timeout==2.2.0
6+
7+
# Main dependencies (ensure compatibility)
8+
numpy>=1.21.0
9+
opencv-python>=4.8.0
10+
Pillow>=9.0.0
11+
pyyaml>=6.0
12+
albumentations>=1.3.0
13+
tqdm>=4.65.0
14+
matplotlib>=3.5.0

0 commit comments

Comments
 (0)