From 38e535d74918b568a99a5c5a76e8c6fa0ef5ab1c Mon Sep 17 00:00:00 2001 From: 100gle Date: Sun, 1 Oct 2023 13:28:58 +0800 Subject: [PATCH] ci: fix the testting ci issue --- backend/src/test/test_openai.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/test/test_openai.py b/backend/src/test/test_openai.py index c257d7b2..49e6c37f 100644 --- a/backend/src/test/test_openai.py +++ b/backend/src/test/test_openai.py @@ -12,9 +12,7 @@ class TestOpenAIParser: @classmethod def setup_class(cls): api_key = os.getenv("OPENAI_API_KEY") or "testing!" - cls.mocker = mock.Mock() - with mock.patch.object(OpenAIParser, "parse", new_callable=cls.mocker): - cls.parser = OpenAIParser(api_key=api_key) + cls.parser = OpenAIParser(api_key=api_key) def test_parse(self): text = "[梦蓝字幕组]New Doraemon 哆啦A梦新番[747][2023.02.25][AVC][1080P][GB_JP][MP4]" @@ -30,7 +28,9 @@ class TestOpenAIParser: "season_raw": "2023.02.25", "source": "AVC", } - self.mocker.return_value = expected - result = self.parser.parse(text=text, asdict=False) - assert json.loads(result) == expected + with mock.patch("module.parser.openai.OpenAIParser.parse") as mocker: + mocker.return_value = json.dumps(expected) + + result = self.parser.parse(text=text, asdict=False) + assert json.loads(result) == expected