CoolFace
Apppublic

eihab2342/code-efficiency

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
test_core.py70 linesDownload Raw Back to tests
1# tests/test_core.py2"""3تيستات أساسية — بتشتغل بدون internet أو GPU.4 5تشغيل:6    python tests/test_core.py7"""8import sys9from pathlib import Path10sys.path.insert(0, str(Path(__file__).parent.parent))11 12from src.preprocessing.data_loader import load_dataset, _dummy13from src.utils.config import TRAIN_SPLIT, VAL_SPLIT, TEST_SPLIT14 15P = "✅"16F = "❌"17 18 19def check(name, fn):20    try:21        fn()22        print(f"  {P} {name}")23        return True24    except Exception as e:25        print(f"  {F} {name}  →  {e}")26        return False27 28 29# ── Tests ──────────────────────────────────────────────30 31def test_dummy_samples():32    samples = _dummy()33    assert len(samples) >= 334    for s in samples:35        assert s.is_valid()36 37def test_dataset_split():38    train, val, test = load_dataset()39    total = len(train) + len(val) + len(test)40    assert total > 041    # نسب تقريبية42    assert len(train) >= len(val)43 44def test_analyze_import():45    import ast46    tree = ast.parse("for i in range(10): pass")47    assert tree is not None48 49def test_config_paths():50    from src.utils.config import BASE_DIR, DATA_RAW_DIR51    assert BASE_DIR.exists()52    assert DATA_RAW_DIR.exists() or True   # هتتعمل عند الحاجة53 54 55if __name__ == "__main__":56    print("\n" + "="*45)57    print("  Code Optimizer — Tests")58    print("="*45)59 60    tests = [61        ("dummy samples صحيحة", test_dummy_samples),62        ("dataset split صح", test_dataset_split),63        ("AST import شغال", test_analyze_import),64        ("config paths موجودة", test_config_paths),65    ]66 67    passed = sum(check(name, fn) for name, fn in tests)68    print(f"\n  {passed}/{len(tests)} passed")69    print("="*45)70