From 001ef6d1007cdedc7f0bf597b336a8ac8014d145 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Sat, 3 Oct 2026 15:46:06 -0700 Subject: [PATCH] Chore: Tidy leftover parentheses and the samples module docstring Co-Authored-By: Claude Sonnet 5.5 --- src/documents/tests/test_api_documents.py | 34 +++++++++++------------ src/paperless_testing/samples.py | 5 ++-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/documents/tests/test_api_documents.py b/src/documents/tests/test_api_documents.py index 3df2a2b8a..573287cb4 100644 --- a/src/documents/tests/test_api_documents.py +++ b/src/documents/tests/test_api_documents.py @@ -1886,7 +1886,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): payload = SimpleUploadedFile( "../../outside.pdf", - (SIMPLE_DIGITAL_PDF).read_bytes(), + SIMPLE_DIGITAL_PDF.read_bytes(), content_type="application/pdf", ) @@ -1915,7 +1915,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - pdf_bytes = (SIMPLE_DIGITAL_PDF).read_bytes() + pdf_bytes = SIMPLE_DIGITAL_PDF.read_bytes() boundary = "paperless-boundary" payload = ( ( @@ -1991,7 +1991,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): def test_upload_insufficient_permissions(self) -> None: self.client.force_authenticate(user=UserFactory(username="testuser2")) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f}, @@ -2041,7 +2041,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"documenst": f}, @@ -2067,7 +2067,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "title": "my custom title"}, @@ -2087,7 +2087,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ) c = Correspondent.objects.create(name="test-corres") - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "correspondent": c.id}, @@ -2106,7 +2106,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "correspondent": 3456}, @@ -2121,7 +2121,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ) dt = DocumentType.objects.create(name="invoice") - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "document_type": dt.id}, @@ -2140,7 +2140,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "document_type": 34578}, @@ -2155,7 +2155,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ) sp = StoragePath.objects.create(name="invoices") - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "storage_path": sp.id}, @@ -2174,7 +2174,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "storage_path": 34578}, @@ -2190,7 +2190,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): t1 = Tag.objects.create(name="tag1") t2 = Tag.objects.create(name="tag2") - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "tags": [t2.id, t1.id]}, @@ -2211,7 +2211,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): t1 = Tag.objects.create(name="tag1") t2 = Tag.objects.create(name="tag2") - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "tags": [t2.id, t1.id, 734563]}, @@ -2235,7 +2235,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): 0, tzinfo=zoneinfo.ZoneInfo("America/Los_Angeles"), ) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "created": created}, @@ -2341,7 +2341,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): w1.actions.add(action1) w1.save() - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", { @@ -2435,7 +2435,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ] for payload in error_payloads: - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: data = {"document": f, **payload} response = self.client.post( "/api/documents/post_document/", @@ -2493,7 +2493,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (SIMPLE_DIGITAL_PDF).open("rb") as f: + with SIMPLE_DIGITAL_PDF.open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "from_webui": True}, diff --git a/src/paperless_testing/samples.py b/src/paperless_testing/samples.py index e73eebb3b..2e823041a 100644 --- a/src/paperless_testing/samples.py +++ b/src/paperless_testing/samples.py @@ -1,7 +1,8 @@ -"""Test sample files that more than one app's tests need. +"""Test sample files shared across tests. A sample used by a single app stays in that app's ``tests/samples`` tree. -Only a file that two or more apps need lives here, exactly once. +Samples needed by more than one app, or stored under more than one name, live +here exactly once. """ import shutil