← 返回卡片

原书出处

Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)

First Edition · 核验版本的摘录快照 · 导入于 2026-11-14T14:46:45.586Z

mock.patch("train.training_helpers._fit_model", return_value=RandomForestClassifier()) model = train_model() assert isinstance(model, RandomForestClassifier) # good example: behavior-focused test def test_train_model_returns_a_trained_model(): test_data = load_test_data() model = train_model(test_data) valid_predictions = [0, 1, 2] prediction = model.predict(test_data[0]) assert prediction in valid_predictions Notice how the second test was easier to understand? The first test is especially common in cases where the subject under test is poorly written and lacks testable boundaries. A convenient workaround

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)/_epub-src/OEBPS/ch05.html

EPUB SHA-256:d98501f374a474910f195f0adfd53c1d895ae8ddc5822476c05cd7ba006ac63d