-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest_infrastructure_validation.py
More file actions
117 lines (97 loc) · 4.02 KB
/
test_infrastructure_validation.py
File metadata and controls
117 lines (97 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"""
Validation tests to ensure the testing infrastructure is properly configured.
"""
import pytest
import sys
import os
from pathlib import Path
import numpy as np
class TestInfrastructureValidation:
"""Test class to validate testing infrastructure setup."""
def test_pytest_working(self):
"""Test that pytest is working correctly."""
assert True
def test_numpy_import(self):
"""Test that numpy can be imported and used."""
arr = np.array([1, 2, 3])
assert arr.shape == (3,)
assert arr.dtype == np.int64 or arr.dtype == np.int32
@pytest.mark.unit
def test_unit_marker(self):
"""Test that unit test marker works."""
assert True
@pytest.mark.integration
def test_integration_marker(self):
"""Test that integration test marker works."""
assert True
@pytest.mark.slow
def test_slow_marker(self):
"""Test that slow test marker works."""
import time
time.sleep(0.01) # Minimal delay
assert True
def test_fixtures_available(self, temp_dir, test_config):
"""Test that custom fixtures are available."""
assert temp_dir.exists()
assert isinstance(test_config, dict)
assert "timeout" in test_config
def test_mock_fixtures(self, mock_angr_project, mock_capstone):
"""Test that mock fixtures work."""
assert mock_angr_project is not None
assert mock_capstone is not None
assert hasattr(mock_angr_project, "arch")
def test_sample_data_fixtures(self, sample_numpy_array, sample_binary_path):
"""Test that sample data fixtures work."""
assert sample_numpy_array.shape == (2, 3)
assert sample_binary_path.exists()
assert sample_binary_path.stat().st_size == 1024
def test_src_module_accessible(self):
"""Test that src module is accessible for imports."""
# Test that we can import from src without errors
# This validates the package structure is correct
try:
import src.utils
except ImportError as e:
# If specific modules don't exist, that's fine for infrastructure test
# Just ensure we can attempt the import
pass
# Just test that src is in the path
src_path = Path(__file__).parent.parent / "src"
assert src_path.exists()
def test_project_structure(self):
"""Test that the project structure is correct."""
project_root = Path(__file__).parent.parent
# Check key directories exist
assert (project_root / "src").exists()
assert (project_root / "tests").exists()
assert (project_root / "tests" / "unit").exists()
assert (project_root / "tests" / "integration").exists()
# Check key files exist
assert (project_root / "pyproject.toml").exists()
assert (project_root / "tests" / "conftest.py").exists()
def test_coverage_will_run(self):
"""Test a simple function to ensure coverage tracking works."""
def simple_function(x):
if x > 0:
return x * 2
else:
return 0
assert simple_function(5) == 10
assert simple_function(-1) == 0
assert simple_function(0) == 0
def test_pytest_mock_available(self, mocker):
"""Test that pytest-mock is available."""
mock_func = mocker.Mock(return_value=42)
assert mock_func() == 42
mock_func.assert_called_once()
def test_environment_variables(self):
"""Test that we can work with environment variables."""
os.environ["TEST_VAR"] = "test_value"
assert os.environ.get("TEST_VAR") == "test_value"
del os.environ["TEST_VAR"]
def test_temp_file_cleanup(self, temp_dir):
"""Test that temporary files are properly cleaned up."""
test_file = temp_dir / "test_cleanup.txt"
test_file.write_text("test content")
assert test_file.exists()
# The cleanup fixture should handle removal after test