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

This commit is contained in:
Trenton Holmes 2023-08-24 16:54:34 -07:00 committed by Trenton H
parent 6c19a0f8c7
commit fe7fb488c0
2 changed files with 16 additions and 4 deletions

View File

@ -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",
)
@mock.patch("documents.migrations.1037_webp_encrypted_thumbnail_conversion.run_convert")
@mock.patch(f"{__name__}.migration_1037_obj.run_convert")
class TestMigrateToEncrytpedWebPThumbnails(TestMigrations):
migrate_from = "1036_alter_savedviewfilterrule_rule_type"
migrate_to = "1037_webp_encrypted_thumbnail_conversion"

View File

@ -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",
)
@mock.patch("documents.migrations.1021_webp_thumbnail_conversion.run_convert")
@mock.patch(f"{__name__}.migration_1021_obj.run_convert")
class TestMigrateWebPThumbnails(TestMigrations):
migrate_from = "1020_merge_20220518_1839"
migrate_to = "1021_webp_thumbnail_conversion"