Fix: Catch new warning when loading the classifier (#5395)

This commit is contained in:
Trenton H
2024-01-14 13:21:17 -08:00
committed by GitHub
parent c0843d71da
commit b8e3dc2dd8
4 changed files with 25 additions and 8 deletions

Binary file not shown.

View File

@@ -1,5 +1,6 @@
import os
import re
import shutil
from pathlib import Path
from unittest import mock
@@ -649,7 +650,7 @@ class TestClassifier(DirectoriesMixin, TestCase):
Path(settings.MODEL_FILE).touch()
self.assertTrue(os.path.exists(settings.MODEL_FILE))
load.side_effect = IncompatibleClassifierVersionError()
load.side_effect = IncompatibleClassifierVersionError("Dummey Error")
self.assertIsNone(load_classifier())
self.assertFalse(os.path.exists(settings.MODEL_FILE))
@@ -661,3 +662,14 @@ class TestClassifier(DirectoriesMixin, TestCase):
load.side_effect = OSError()
self.assertIsNone(load_classifier())
self.assertTrue(os.path.exists(settings.MODEL_FILE))
def test_load_old_classifier_version(self):
shutil.copy(
os.path.join(os.path.dirname(__file__), "data", "v1.17.4.model.pickle"),
self.dirs.scratch_dir,
)
with override_settings(
MODEL_FILE=self.dirs.scratch_dir / "v1.17.4.model.pickle",
):
classifier = load_classifier()
self.assertIsNone(classifier)