Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Do some trickery to support Python 3.11 and mocking invalid module names

Trenton Holmesfe7fb488c082
diff --git a/src/documents/tests/test_migration_encrypted_webp_conversion.py b/src/documents/tests/test_migration_encrypted_webp_conversion.py
index fbb5a8611..d8c5ddd52 100644
--- a/src/documents/tests/test_migration_encrypted_webp_conversion.py
+++ b/src/documents/tests/test_migration_encrypted_webp_conversion.py
@@ -1,3 +1,4 @@
+import importlib
import shutil
import tempfile
from pathlib import Path
@@ -10,12 +11,17 @@ from django.test import override_settings
from documents.tests.utils import TestMigrations
+# https://github.com/python/cpython/issues/100950
+migration_1037_obj = importlib.import_module(
+ "documents.migrations.1037_webp_encrypted_thumbnail_conversion",
+)
+
@override_settings(PASSPHRASE="test")
@mock.patch(
- "documents.migrations.1037_webp_encrypted_thumbnail_conversion.multiprocessing.pool.Pool.map",
+ f"{__name__}.migration_1037_obj.multiprocessing.pool.Pool.map",
)
[email protected]("documents.migrations.1037_webp_encrypted_thumbnail_conversion.run_convert")
[email protected](f"{__name__}.migration_1037_obj.run_convert")
class TestMigrateToEncrytpedWebPThumbnails(TestMigrations):
migrate_from = "1036_alter_savedviewfilterrule_rule_type"
migrate_to = "1037_webp_encrypted_thumbnail_conversion"
diff --git a/src/documents/tests/test_migration_webp_conversion.py b/src/documents/tests/test_migration_webp_conversion.py
index db5fd83af..18367cbe6 100644
--- a/src/documents/tests/test_migration_webp_conversion.py
+++ b/src/documents/tests/test_migration_webp_conversion.py
@@ -1,3 +1,4 @@
+import importlib
import shutil
import tempfile
from pathlib import Path
@@ -10,11 +11,16 @@ from django.test import override_settings
from documents.tests.utils import TestMigrations
+# https://github.com/python/cpython/issues/100950
+migration_1021_obj = importlib.import_module(
+ "documents.migrations.1021_webp_thumbnail_conversion",
+)
+
@mock.patch(
- "documents.migrations.1021_webp_thumbnail_conversion.multiprocessing.pool.Pool.map",
+ f"{__name__}.migration_1021_obj.multiprocessing.pool.Pool.map",
)
[email protected]("documents.migrations.1021_webp_thumbnail_conversion.run_convert")
[email protected](f"{__name__}.migration_1021_obj.run_convert")
class TestMigrateWebPThumbnails(TestMigrations):
migrate_from = "1020_merge_20220518_1839"
migrate_to = "1021_webp_thumbnail_conversion"