Skip to content

Commit ec9a906

Browse files
committed
Fix test failures: pytest collection warning and validator bug
This commit fixes two test issues discovered in CI: 1. Pytest Collection Warning (test_base_ingestor.py): - Renamed TestIngestor to MockIngestor - Pytest was incorrectly treating the helper class as a test class - The class starts with "Test" but is a concrete implementation for testing - Updated all references in fixtures and assertions 2. Validator Test Failures (test_qlib_binary_writer.py): - Fixed bug in QlibBinaryValidator._validate_instruments() - Instruments file format is tab-separated: SYMBOL\tstart_date\tend_date - Validator was not splitting by tab, causing symbol lookups to fail - Now properly extracts just the symbol field (first column) - This fixes both test_validator_features and test_validator_full Test Results: - All 123 unit tests now pass (previously 2 failures, 1 warning) - test_base_ingestor.py: 11/11 passed - test_qlib_binary_writer.py: 20/20 passed (including previously failing tests) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ff312aa commit ec9a906

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/transform/qlib_binary_validator.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,15 @@ def _validate_instruments(self, data_type: str) -> Dict[str, Any]:
133133
return result
134134

135135
with open(instruments_file) as f:
136-
symbols = [line.strip() for line in f if line.strip()]
136+
# Instruments file format: SYMBOL\tstart_date\tend_date
137+
# Extract just the symbol (first field)
138+
symbols = []
139+
for line in f:
140+
line = line.strip()
141+
if line:
142+
# Split by tab and take first field (symbol)
143+
symbol = line.split('\t')[0]
144+
symbols.append(symbol)
137145

138146
if len(symbols) == 0:
139147
result['errors'] = result.get('errors', [])

tests/unit/test_base_ingestor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from src.ingest.base_ingestor import BaseIngestor, IngestionError
1414

1515

16-
class TestIngestor(BaseIngestor):
16+
class MockIngestor(BaseIngestor):
1717
"""Concrete implementation for testing"""
1818

1919
def ingest_date(self, date, data, symbols=None):
@@ -36,7 +36,7 @@ def test_config():
3636
@pytest.fixture
3737
def test_ingestor(tmp_path, test_config):
3838
"""Create test ingestor instance"""
39-
return TestIngestor(
39+
return MockIngestor(
4040
data_type='stocks_daily',
4141
output_root=tmp_path / 'parquet',
4242
config=test_config
@@ -182,7 +182,7 @@ def test_memory_monitor_integration(test_ingestor):
182182
def test_repr(test_ingestor):
183183
"""Test string representation"""
184184
repr_str = repr(test_ingestor)
185-
assert 'TestIngestor' in repr_str
185+
assert 'MockIngestor' in repr_str
186186
assert 'stocks_daily' in repr_str
187187

188188

0 commit comments

Comments
 (0)