Format and lint with ruff (#1263)

This commit is contained in:
Sascha Ißbrücker
2026-01-04 12:13:48 +01:00
committed by GitHub
parent 4d82fefa4e
commit 3b26190df5
178 changed files with 601 additions and 739 deletions

View File

@@ -1,8 +1,9 @@
from unittest import mock
from bookmarks.services import website_loader
from django.test import TestCase
from bookmarks.services import website_loader
class MockStreamingResponse:
def __init__(self, num_chunks, chunk_size, insert_head_after_chunk=None):
@@ -12,7 +13,7 @@ class MockStreamingResponse:
self.chunks.append(chunk.encode("utf-8"))
if index == insert_head_after_chunk:
self.chunks.append("</head>".encode("utf-8"))
self.chunks.append(b"</head>")
def iter_content(self, **kwargs):
return self.chunks
@@ -92,7 +93,7 @@ class WebsiteLoaderTestCase(TestCase):
def test_load_page_removes_bytes_after_end_of_head(self):
with mock.patch("requests.get") as mock_get:
mock_response = MockStreamingResponse(num_chunks=1, chunk_size=0)
mock_response.chunks[0] = "<head>人</head>".encode("utf-8")
mock_response.chunks[0] = "<head>人</head>".encode()
# add a single byte that can't be decoded to utf-8
mock_response.chunks[0] += 0xFF.to_bytes(1, "big")
mock_get.return_value = mock_response