mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
ruff-fix
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from unittest.mock import Mock, patch
|
||||
from typing import Any, Dict, Generator
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from unittest.mock import Mock, patch
|
||||
from types import SimpleNamespace
|
||||
import uuid
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
|
||||
from application.llm.handlers.handler_creator import LLMHandlerCreator
|
||||
from application.llm.handlers.base import LLMHandler
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import pytest
|
||||
from unittest.mock import Mock
|
||||
from types import SimpleNamespace
|
||||
|
||||
from application.llm.handlers.openai import OpenAILLMHandler
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import sys
|
||||
import types
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
import types
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ def test_html_parser_parse_file():
|
||||
mock_doc.page_content = "Extracted HTML content"
|
||||
mock_doc.metadata = {"source": "test.html"}
|
||||
|
||||
import types, sys
|
||||
fake_lc = types.ModuleType("langchain_community")
|
||||
fake_dl = types.ModuleType("langchain_community.document_loaders")
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock, mock_open
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, mock_open
|
||||
|
||||
@@ -40,7 +39,8 @@ def test_json_parser_row_joiner_config():
|
||||
|
||||
|
||||
def test_json_parser_forwards_json_config():
|
||||
pf = lambda s: 1.23
|
||||
def pf(s):
|
||||
return 1.23
|
||||
parser = JSONParser(json_config={"parse_float": pf})
|
||||
with patch("builtins.open", mock_open(read_data="[]")):
|
||||
with patch("json.load", return_value=[]) as mock_load:
|
||||
|
||||
@@ -2,17 +2,19 @@ from pathlib import Path
|
||||
from unittest.mock import mock_open, patch
|
||||
|
||||
import pytest
|
||||
import tiktoken
|
||||
|
||||
from application.parser.file.markdown_parser import MarkdownParser
|
||||
|
||||
|
||||
class _Enc:
|
||||
def encode(self, s: str):
|
||||
return list(s)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _patch_tokenizer(monkeypatch):
|
||||
import application.parser.file.markdown_parser as mdp
|
||||
monkeypatch.setattr(mdp.tiktoken, "get_encoding", lambda _: _Enc())
|
||||
|
||||
from application.parser.file.markdown_parser import MarkdownParser
|
||||
monkeypatch.setattr(tiktoken, "get_encoding", lambda _: _Enc())
|
||||
|
||||
def test_markdown_init_parser():
|
||||
parser = MarkdownParser()
|
||||
|
||||
@@ -30,7 +30,8 @@ def _fake_presentation_with(slides_shapes_texts):
|
||||
def test_pptx_parser_concat_true():
|
||||
slides = [["Hello ", "World"], ["Slide2"]]
|
||||
FakePres = _fake_presentation_with(slides)
|
||||
import sys, types
|
||||
import sys
|
||||
import types
|
||||
fake_pptx = types.ModuleType("pptx")
|
||||
fake_pptx.Presentation = FakePres
|
||||
parser = PPTXParser()
|
||||
@@ -42,7 +43,8 @@ def test_pptx_parser_concat_true():
|
||||
def test_pptx_parser_list_mode():
|
||||
slides = [[" A ", "B"], [" C "]]
|
||||
FakePres = _fake_presentation_with(slides)
|
||||
import sys, types
|
||||
import sys
|
||||
import types
|
||||
fake_pptx = types.ModuleType("pptx")
|
||||
fake_pptx.Presentation = FakePres
|
||||
parser = PPTXParser()
|
||||
|
||||
Reference in New Issue
Block a user