# tests/test_model.py import joblib import pandas as pd def test_model_prediction(): # 加载模型 model = joblib.load("../telco_churn_model.pkl") # 构造测试数据 test_data = pd.DataFrame({ "tenure": [2], "MonthlyCharges": [89.99], "Contract": ["Month-to-month"] }) # 测试预测是否正常运行 pred = model.predict(test_data) assert pred is not None # 只要能预测就通过