Spaces:
Running
Running
File size: 2,036 Bytes
178345a | 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 | """Pytest configuration for tests."""
import sys
from pathlib import Path
import tempfile
import pandas as pd
import pytest
# Add parent directory (project root) to sys.path so that imports work
sys.path.insert(0, str(Path(__file__).parent.parent))
@pytest.fixture(scope="session", autouse=True)
def setup_features_csv():
"""Create a temporary features_train.csv for tests if it doesn't exist.
This ensures tests can run in CI environments without the data files.
"""
features_path = Path("data/processed/features_train.csv")
# Skip if file already exists
if features_path.exists():
return
# Create minimal feature set with required columns for tests
features = [
"CODE_GENDER",
"FLAG_OWN_CAR",
"FLAG_OWN_REALTY",
"CNT_CHILDREN",
"AMT_INCOME_TOTAL",
"AMT_CREDIT",
"AMT_ANNUITY",
"AMT_GOODS_PRICE",
"REGION_POPULATION_RELATIVE",
"DAYS_BIRTH",
"DAYS_EMPLOYED",
"DAYS_REGISTRATION",
"DAYS_ID_PUBLISH",
"OWN_CAR_AGE",
"FLAG_MOBIL",
"FLAG_EMP_PHONE",
"FLAG_WORK_PHONE",
"FLAG_CONT_MOBILE",
"FLAG_PHONE",
"FLAG_EMAIL",
"CNT_FAM_MEMBERS",
"REGION_RATING_CLIENT",
"REGION_RATING_CLIENT_W_CITY",
"HOUR_APPR_PROCESS_START",
"REG_REGION_NOT_LIVE_REGION",
"REG_REGION_NOT_WORK_REGION",
"LIVE_REGION_NOT_WORK_REGION",
"PAYMENT_RATE",
"INCOME_CREDIT_PERC",
"INCOME_PER_PERSON",
"ANNUITY_INCOME_PERC",
"DAYS_EMPLOYED_PERC",
"NAME_CONTRACT_TYPE_Cash_loans",
"NAME_CONTRACT_TYPE_Revolving_loans",
]
# Create directory if it doesn't exist
features_path.parent.mkdir(parents=True, exist_ok=True)
# Create minimal dataframe and save
df = pd.DataFrame({col: [0.0] for col in features})
df.insert(0, "SK_ID_CURR", [1])
df.insert(1, "TARGET", [0])
df.to_csv(features_path, index=False)
|