mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
test_helpers: Make use_db_models generic.
We use this decorator on subclasses of `MigrationsTestCase`, which does not have `self`s being `MigrationsTestCase`, but the corresponding subclass. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
3404282927
commit
9d1ef72f08
@@ -570,10 +570,13 @@ def create_s3_buckets(*bucket_names: str) -> List[Bucket]:
|
|||||||
return buckets
|
return buckets
|
||||||
|
|
||||||
|
|
||||||
|
TestCaseT = TypeVar("TestCaseT", bound="MigrationsTestCase")
|
||||||
|
|
||||||
|
|
||||||
def use_db_models(
|
def use_db_models(
|
||||||
method: Callable[["MigrationsTestCase", StateApps], None]
|
method: Callable[[TestCaseT, StateApps], None]
|
||||||
) -> Callable[["MigrationsTestCase", StateApps], None]: # nocoverage
|
) -> Callable[[TestCaseT, StateApps], None]: # nocoverage
|
||||||
def method_patched_with_mock(self: "MigrationsTestCase", apps: StateApps) -> None:
|
def method_patched_with_mock(self: TestCaseT, apps: StateApps) -> None:
|
||||||
ArchivedAttachment = apps.get_model("zerver", "ArchivedAttachment")
|
ArchivedAttachment = apps.get_model("zerver", "ArchivedAttachment")
|
||||||
ArchivedMessage = apps.get_model("zerver", "ArchivedMessage")
|
ArchivedMessage = apps.get_model("zerver", "ArchivedMessage")
|
||||||
ArchivedUserMessage = apps.get_model("zerver", "ArchivedUserMessage")
|
ArchivedUserMessage = apps.get_model("zerver", "ArchivedUserMessage")
|
||||||
|
|||||||
Reference in New Issue
Block a user