From e0e001758a88932e5b708a28a499fe5fe8224b0b Mon Sep 17 00:00:00 2001 From: Ryan Dick Date: Fri, 6 Oct 2023 18:26:06 -0400 Subject: [PATCH] Remove @slow decorator in favor of @pytest.mark.slow. --- docs/contributing/TESTS.md | 7 ++++--- invokeai/backend/util/test_utils.py | 10 ---------- tests/backend/ip_adapter/test_ip_adapter.py | 4 ++-- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/docs/contributing/TESTS.md b/docs/contributing/TESTS.md index aab6cfa635..8d823bb4e9 100644 --- a/docs/contributing/TESTS.md +++ b/docs/contributing/TESTS.md @@ -3,7 +3,7 @@ We use `pytest` to run the backend python tests. (See [pyproject.toml](/pyproject.toml) for the default `pytest` options.) ## Fast vs. Slow -All tests are categorized as either 'fast' (no test annotation) or 'slow' (annotated with the `@slow` decorator). +All tests are categorized as either 'fast' (no test annotation) or 'slow' (annotated with the `@pytest.mark.slow` decorator). 'Fast' tests are run to validate every PR, and are fast enough that they can be run routinely during development. @@ -47,12 +47,13 @@ There are a few things to keep in mind when adding tests that depend on models. There are several utilities to help with model setup for tests. Here is a sample test that depends on a model: ```python +import pytest import torch from invokeai.backend.model_management.models.base import BaseModelType, ModelType -from invokeai.backend.util.test_utils import install_and_load_model, slow +from invokeai.backend.util.test_utils import install_and_load_model -@slow +@pytest.mark.slow def test_model(model_installer, torch_device): model_info = install_and_load_model( model_installer=model_installer, diff --git a/invokeai/backend/util/test_utils.py b/invokeai/backend/util/test_utils.py index a41bdde8f8..1c7b538882 100644 --- a/invokeai/backend/util/test_utils.py +++ b/invokeai/backend/util/test_utils.py @@ -11,16 +11,6 @@ from invokeai.backend.model_management.model_manager import ModelInfo from invokeai.backend.model_management.models.base import BaseModelType, ModelNotFoundException, ModelType, SubModelType -def slow(test_case): - """Decorator for slow tests. - - Tests should be marked as slow if they download a model, run model inference, or do anything else slow. To judge - whether a test is 'slow', consider how it would perform in a CPU-only environment with a low-bandwidth internet - connection. - """ - return pytest.mark.slow(test_case) - - @pytest.fixture(scope="session") def torch_device(): return "cuda" if torch.cuda.is_available() else "cpu" diff --git a/tests/backend/ip_adapter/test_ip_adapter.py b/tests/backend/ip_adapter/test_ip_adapter.py index b84f5836be..1248ead98b 100644 --- a/tests/backend/ip_adapter/test_ip_adapter.py +++ b/tests/backend/ip_adapter/test_ip_adapter.py @@ -2,7 +2,7 @@ import pytest import torch from invokeai.backend.model_management.models.base import BaseModelType, ModelType, SubModelType -from invokeai.backend.util.test_utils import install_and_load_model, slow +from invokeai.backend.util.test_utils import install_and_load_model def build_dummy_sd15_unet_input(torch_device): @@ -38,7 +38,7 @@ def build_dummy_sd15_unet_input(torch_device): }, ], ) -@slow +@pytest.mark.slow def test_ip_adapter_unet_patch(model_params, model_installer, torch_device): """Smoke test that IP-Adapter weights can be loaded and used to patch a UNet.""" ip_adapter_info = install_and_load_model(