From e8c4e4645bb23ff61bb2650eb6c5aa26921063ee Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Mon, 15 Jul 2024 17:53:10 -0700 Subject: [PATCH] Add flake8-pytest-style --- pyproject.toml | 6 ++++- .../test_pgvector_vector_store_driver.py | 6 ++--- tests/unit/artifacts/test_audio_artifact.py | 2 +- .../artifacts/test_base_media_artifact.py | 2 +- tests/unit/artifacts/test_image_artifact.py | 2 +- tests/unit/chunkers/test_markdown_chunker.py | 2 +- tests/unit/chunkers/test_pdf_chunker.py | 2 +- tests/unit/chunkers/test_text_chunker.py | 2 +- tests/unit/common/test_prompt_stack.py | 2 +- .../test_amazon_bedrock_structure_config.py | 10 +++---- .../config/test_anthropic_structure_config.py | 8 +++--- .../test_azure_openai_structure_config.py | 6 ++--- .../config/test_cohere_structure_config.py | 4 +-- .../config/test_google_structure_config.py | 6 ++--- .../config/test_openai_structure_config.py | 6 ++--- tests/unit/config/test_structure_config.py | 4 +-- ..._amazon_bedrock_cohere_embedding_driver.py | 2 +- ...t_amazon_bedrock_titan_embedding_driver.py | 2 +- .../test_azure_openai_embedding_driver.py | 2 +- .../embedding/test_base_embedding_driver.py | 2 +- .../embedding/test_dummy_embedding_driver.py | 2 +- ...st_sagemaker_jumpstart_embedding_driver.py | 6 ++--- .../test_amazon_sqs_event_listener_driver.py | 8 +++--- .../test_aws_iot_event_listener_driver.py | 8 +++--- ...st_griptape_cloud_event_listener_driver.py | 5 ++-- .../test_pusher_event_listener_driver.py | 6 ++--- .../test_webhook_event_listener_driver.py | 4 +-- .../test_amazon_s3_file_manager_driver.py | 26 +++++++++---------- .../test_local_file_manager_driver.py | 14 +++++----- ...table_diffusion_image_generation_driver.py | 8 +++--- ...st_azure_openai_image_generation_driver.py | 2 +- .../test_dummy_image_generation_driver.py | 2 +- .../test_leonardo_image_generation_driver.py | 2 +- .../test_openai_image_generation_driver.py | 2 +- ...ock_stable_diffusion_image_model_driver.py | 6 ++--- .../test_bedrock_titan_image_model_driver.py | 6 ++--- .../test_amazon_bedrock_image_query_driver.py | 8 +++--- .../test_anthropic_image_query_driver.py | 2 +- .../test_azure_openai_image_query_driver.py | 2 +- .../test_dummy_image_query_driver.py | 2 +- .../test_openai_image_query_driver.py | 2 +- ...est_dynamodb_conversation_memory_driver.py | 2 +- .../test_local_conversation_memory_driver.py | 2 +- .../test_redis_conversation_memory_driver.py | 4 +-- .../test_amazon_bedrock_prompt_driver.py | 6 ++--- .../prompt/test_anthropic_prompt_driver.py | 6 ++--- .../test_azure_openai_chat_prompt_driver.py | 4 +-- .../prompt/test_cohere_prompt_driver.py | 4 +-- .../prompt/test_dummy_prompt_driver.py | 2 +- .../prompt/test_google_prompt_driver.py | 6 ++--- .../test_hugging_face_hub_prompt_driver.py | 6 ++--- ...est_hugging_face_pipeline_prompt_driver.py | 2 +- .../prompt/test_ollama_prompt_driver.py | 4 +-- .../prompt/test_openai_chat_prompt_driver.py | 8 +++--- .../rerank/test_cohere_rerank_driver.py | 2 +- .../sql/test_amazon_redshift_sql_driver.py | 4 +-- .../drivers/sql/test_snowflake_sql_driver.py | 14 +++++----- tests/unit/drivers/sql/test_sql_driver.py | 2 +- ...est_griptape_cloud_structure_run_driver.py | 2 +- ...test_elevenlabs_audio_generation_driver.py | 2 +- .../test_openai_audio_transcription_driver.py | 4 +-- ...t_amazon_opensearch_vector_store_driver.py | 2 +- .../test_azure_mongodb_vector_store_driver.py | 11 +++++--- .../test_base_local_vector_store_driver.py | 2 +- .../vector/test_dummy_vector_store_driver.py | 2 +- ...loud_knowledge_base_vector_store_driver.py | 2 +- .../vector/test_local_vector_store_driver.py | 2 +- .../vector/test_marqo_vector_store_driver.py | 2 +- .../test_mongodb_atlas_vector_store_driver.py | 11 +++++--- .../test_opensearch_vector_store_driver.py | 2 +- ...st_persistent_local_vector_store_driver.py | 4 +-- .../test_pgvector_vector_store_driver.py | 6 ++--- .../test_pinecone_vector_storage_driver.py | 4 +-- .../vector/test_qdrant_vector_store_driver.py | 4 +-- .../vector/test_redis_vector_store_driver.py | 8 +++--- .../test_markdownify_web_scraper_driver.py | 2 +- .../test_proxy_web_scraper_driver.py | 4 +-- .../test_trafilatura_web_scraper_driver.py | 4 +-- .../test_duck_duck_go_web_search_driver.py | 4 +-- .../test_google_web_search_driver.py | 5 ++-- .../extraction/test_csv_extraction_engine.py | 2 +- .../extraction/test_json_extraction_engine.py | 2 +- ...est_footnote_prompt_response_rag_module.py | 2 +- .../test_prompt_response_rag_module.py | 2 +- .../test_text_chunks_response_rag_module.py | 2 +- .../test_text_chunks_rerank_rag_module.py | 2 +- .../test_text_loader_retrieval_rag_module.py | 2 +- tests/unit/engines/rag/test_rag_engine.py | 2 +- .../summary/test_prompt_summary_engine.py | 2 +- .../events/test_completion_chunk_event.py | 2 +- tests/unit/events/test_event_listener.py | 2 +- .../test_finish_actions_subtask_event.py | 2 +- tests/unit/events/test_finish_prompt_event.py | 2 +- .../events/test_finish_structure_run_event.py | 2 +- tests/unit/events/test_finish_task_event.py | 2 +- .../test_start_actions_subtask_event.py | 2 +- tests/unit/events/test_start_prompt_event.py | 2 +- .../events/test_start_structure_run_event.py | 2 +- tests/unit/events/test_start_task_event.py | 2 +- tests/unit/loaders/conftest.py | 6 ++--- tests/unit/loaders/test_audio_loader.py | 6 ++--- tests/unit/loaders/test_csv_loader.py | 2 +- tests/unit/loaders/test_dataframe_loader.py | 2 +- tests/unit/loaders/test_email_loader.py | 6 ++--- tests/unit/loaders/test_image_loader.py | 8 +++--- tests/unit/loaders/test_pdf_loader.py | 4 +-- tests/unit/loaders/test_sql_loader.py | 2 +- tests/unit/loaders/test_web_loader.py | 4 +-- .../meta/test_action_subtask_meta_entry.py | 2 +- tests/unit/memory/meta/test_meta_memory.py | 2 +- .../storage/test_blob_artifact_storage.py | 2 +- .../storage/test_text_artifact_storage.py | 2 +- tests/unit/memory/tool/test_task_memory.py | 4 +-- tests/unit/mixins/test_activity_mixin.py | 2 +- tests/unit/structures/test_agent.py | 2 +- tests/unit/structures/test_pipeline.py | 6 ++--- tests/unit/structures/test_workflow.py | 7 +++-- .../tasks/test_audio_transcription_task.py | 4 +-- .../unit/tasks/test_base_audio_input_task.py | 2 +- tests/unit/tasks/test_base_task.py | 2 +- tests/unit/tasks/test_csv_extraction_task.py | 2 +- tests/unit/tasks/test_extraction_task.py | 2 +- tests/unit/tasks/test_image_query_task.py | 6 ++--- .../test_inpainting_image_generation_task.py | 4 +-- tests/unit/tasks/test_json_extraction_task.py | 2 +- .../test_outpainting_image_generation_task.py | 4 +-- tests/unit/tasks/test_rag_task.py | 2 +- tests/unit/tasks/test_tool_task.py | 2 +- .../test_variation_image_generation_task.py | 4 +-- .../test_amazon_bedrock_tokenizer.py | 8 +++--- .../tokenizers/test_anthropic_tokenizer.py | 8 +++--- .../unit/tokenizers/test_cohere_tokenizer.py | 2 +- tests/unit/tokenizers/test_dummy_tokenizer.py | 2 +- .../unit/tokenizers/test_google_tokenizer.py | 8 +++--- .../tokenizers/test_hugging_face_tokenizer.py | 2 +- .../unit/tokenizers/test_openai_tokenizer.py | 13 +++++----- .../unit/tokenizers/test_simple_tokenizer.py | 2 +- .../tokenizers/test_voyageai_tokenizer.py | 8 +++--- tests/unit/tools/test_aws_iam.py | 6 ++--- tests/unit/tools/test_aws_s3.py | 6 ++--- tests/unit/tools/test_base_tool.py | 4 +-- tests/unit/tools/test_computer.py | 2 +- tests/unit/tools/test_email_client.py | 6 ++--- tests/unit/tools/test_file_manager.py | 4 +-- tests/unit/tools/test_google_docs_client.py | 2 +- ...st_griptape_cloud_knowledge_base_client.py | 8 +++--- ...test_inpainting_image_generation_client.py | 6 ++--- tests/unit/tools/test_openweather_client.py | 2 +- ...test_outpainting_image_variation_client.py | 6 ++--- .../test_prompt_image_generation_client.py | 4 +-- tests/unit/tools/test_rest_api_client.py | 2 +- tests/unit/tools/test_sql_client.py | 2 +- tests/unit/tools/test_structure_run_client.py | 2 +- tests/unit/tools/test_task_memory_client.py | 2 +- .../unit/tools/test_text_to_speech_client.py | 4 +-- tests/unit/tools/test_transcription_client.py | 4 +-- .../test_variation_image_generation_client.py | 6 ++--- tests/unit/tools/test_vector_store_client.py | 2 +- tests/unit/tools/test_web_scraper.py | 2 +- tests/unit/tools/test_web_search.py | 4 +-- .../utils/test_load_artifact_from_memory.py | 18 +++++-------- tests/unit/utils/test_message_stack.py | 2 +- tests/unit/utils/test_stream.py | 2 +- 163 files changed, 335 insertions(+), 337 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a627418e3f..ebd6349244 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -216,6 +216,7 @@ select = [ "COM", # flake8-commas "C4", # flake8-comprehensions "ANN", # flake8-annotations + "PT", # flake8-pytest-style ] ignore = [ "UP007", # non-pep604-annotation @@ -237,12 +238,15 @@ ignore = [ "ANN101", # missing-type-self "ANN102", # missing-type-cls "ANN401", # any-type + "PT011", # pytest-raises-too-broad ] [tool.ruff.lint.pydocstyle] convention = "google" [tool.ruff.lint.per-file-ignores] -"__init__.py" = ["I"] +"__init__.py" = [ + "I" # isort +] "tests/*" = [ "ANN001", # missing-type-function-argument "ANN201", # missing-return-type-undocumented-public-function diff --git a/tests/integration/drivers/vector/test_pgvector_vector_store_driver.py b/tests/integration/drivers/vector/test_pgvector_vector_store_driver.py index c3ce6a09d9..e592fce065 100644 --- a/tests/integration/drivers/vector/test_pgvector_vector_store_driver.py +++ b/tests/integration/drivers/vector/test_pgvector_vector_store_driver.py @@ -15,11 +15,11 @@ class TestPgVectorVectorStoreDriver: vec1 = [0.1, 0.2, 0.3] vec2 = [0.4, 0.5, 0.6] - @pytest.fixture + @pytest.fixture() def embedding_driver(self): return MockEmbeddingDriver() - @pytest.fixture + @pytest.fixture() def vector_store_driver(self, embedding_driver): driver = PgVectorVectorStoreDriver( connection_string=self.connection_string, embedding_driver=embedding_driver, table_name=self.table_name @@ -30,8 +30,8 @@ def vector_store_driver(self, embedding_driver): return driver def test_initialize_requires_engine_or_connection_string(self, embedding_driver): + driver = PgVectorVectorStoreDriver(embedding_driver=embedding_driver, table_name=self.table_name) with pytest.raises(ValueError): - driver = PgVectorVectorStoreDriver(embedding_driver=embedding_driver, table_name=self.table_name) driver.setup() def test_initialize_accepts_engine(self, embedding_driver): diff --git a/tests/unit/artifacts/test_audio_artifact.py b/tests/unit/artifacts/test_audio_artifact.py index e4c01a192d..6d44c05b3e 100644 --- a/tests/unit/artifacts/test_audio_artifact.py +++ b/tests/unit/artifacts/test_audio_artifact.py @@ -4,7 +4,7 @@ class TestAudioArtifact: - @pytest.fixture + @pytest.fixture() def audio_artifact(self): return AudioArtifact(value=b"some binary audio data", format="pcm", model="provider/model", prompt="two words") diff --git a/tests/unit/artifacts/test_base_media_artifact.py b/tests/unit/artifacts/test_base_media_artifact.py index b07e5db799..c85d070fef 100644 --- a/tests/unit/artifacts/test_base_media_artifact.py +++ b/tests/unit/artifacts/test_base_media_artifact.py @@ -9,7 +9,7 @@ class TestMediaArtifact: class ImaginaryMediaArtifact(MediaArtifact): media_type: str = "imagination" - @pytest.fixture + @pytest.fixture() def media_artifact(self): return self.ImaginaryMediaArtifact(value=b"some binary dream data", format="dream") diff --git a/tests/unit/artifacts/test_image_artifact.py b/tests/unit/artifacts/test_image_artifact.py index 885f262341..a722ebd911 100644 --- a/tests/unit/artifacts/test_image_artifact.py +++ b/tests/unit/artifacts/test_image_artifact.py @@ -4,7 +4,7 @@ class TestImageArtifact: - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact( value=b"some binary png image data", diff --git a/tests/unit/chunkers/test_markdown_chunker.py b/tests/unit/chunkers/test_markdown_chunker.py index 1ee0f71c7e..30db64611c 100644 --- a/tests/unit/chunkers/test_markdown_chunker.py +++ b/tests/unit/chunkers/test_markdown_chunker.py @@ -7,7 +7,7 @@ class TestTextChunker: - @pytest.fixture + @pytest.fixture() def chunker(self): return MarkdownChunker(max_tokens=MAX_TOKENS) diff --git a/tests/unit/chunkers/test_pdf_chunker.py b/tests/unit/chunkers/test_pdf_chunker.py index 3578c864d0..dc072ca364 100644 --- a/tests/unit/chunkers/test_pdf_chunker.py +++ b/tests/unit/chunkers/test_pdf_chunker.py @@ -9,7 +9,7 @@ class TestPdfChunker: - @pytest.fixture + @pytest.fixture() def chunker(self): return PdfChunker(max_tokens=MAX_TOKENS) diff --git a/tests/unit/chunkers/test_text_chunker.py b/tests/unit/chunkers/test_text_chunker.py index 67e07ea120..d9d01f16c0 100644 --- a/tests/unit/chunkers/test_text_chunker.py +++ b/tests/unit/chunkers/test_text_chunker.py @@ -8,7 +8,7 @@ class TestTextChunker: - @pytest.fixture + @pytest.fixture() def chunker(self): return TextChunker(max_tokens=MAX_TOKENS) diff --git a/tests/unit/common/test_prompt_stack.py b/tests/unit/common/test_prompt_stack.py index ee7cd21ce4..e69fe710db 100644 --- a/tests/unit/common/test_prompt_stack.py +++ b/tests/unit/common/test_prompt_stack.py @@ -12,7 +12,7 @@ class TestPromptStack: - @pytest.fixture + @pytest.fixture() def prompt_stack(self): return PromptStack() diff --git a/tests/unit/config/test_amazon_bedrock_structure_config.py b/tests/unit/config/test_amazon_bedrock_structure_config.py index 44206c6889..afe9b37204 100644 --- a/tests/unit/config/test_amazon_bedrock_structure_config.py +++ b/tests/unit/config/test_amazon_bedrock_structure_config.py @@ -1,21 +1,21 @@ import boto3 -from pytest import fixture +import pytest from griptape.config import AmazonBedrockStructureConfig from tests.utils.aws import mock_aws_credentials class TestAmazonBedrockStructureConfig: - @fixture(autouse=True) - def run_before_and_after_tests(self): + @pytest.fixture(autouse=True) + def _run_before_and_after_tests(self): mock_aws_credentials() - @fixture + @pytest.fixture() def config(self): mock_aws_credentials() return AmazonBedrockStructureConfig() - @fixture + @pytest.fixture() def config_with_values(self): return AmazonBedrockStructureConfig( session=boto3.Session( diff --git a/tests/unit/config/test_anthropic_structure_config.py b/tests/unit/config/test_anthropic_structure_config.py index dbf402bb87..05519fa5e3 100644 --- a/tests/unit/config/test_anthropic_structure_config.py +++ b/tests/unit/config/test_anthropic_structure_config.py @@ -1,15 +1,15 @@ -from pytest import fixture +import pytest from griptape.config import AnthropicStructureConfig class TestAnthropicStructureConfig: - @fixture(autouse=True) - def mock_anthropic(self, mocker): + @pytest.fixture(autouse=True) + def _mock_anthropic(self, mocker): mocker.patch("anthropic.Anthropic") mocker.patch("voyageai.Client") - @fixture + @pytest.fixture() def config(self): return AnthropicStructureConfig() diff --git a/tests/unit/config/test_azure_openai_structure_config.py b/tests/unit/config/test_azure_openai_structure_config.py index ab5fdf30dd..dcdc3a1dc6 100644 --- a/tests/unit/config/test_azure_openai_structure_config.py +++ b/tests/unit/config/test_azure_openai_structure_config.py @@ -1,14 +1,14 @@ -from pytest import fixture +import pytest from griptape.config import AzureOpenAiStructureConfig class TestAzureOpenAiStructureConfig: - @fixture(autouse=True) + @pytest.fixture(autouse=True) def mock_openai(self, mocker): return mocker.patch("openai.AzureOpenAI") - @fixture + @pytest.fixture() def config(self): return AzureOpenAiStructureConfig( azure_endpoint="http://localhost:8080", diff --git a/tests/unit/config/test_cohere_structure_config.py b/tests/unit/config/test_cohere_structure_config.py index 9074e6af1a..113a589ec4 100644 --- a/tests/unit/config/test_cohere_structure_config.py +++ b/tests/unit/config/test_cohere_structure_config.py @@ -1,10 +1,10 @@ -from pytest import fixture +import pytest from griptape.config import CohereStructureConfig class TestCohereStructureConfig: - @fixture + @pytest.fixture() def config(self): return CohereStructureConfig(api_key="api_key") diff --git a/tests/unit/config/test_google_structure_config.py b/tests/unit/config/test_google_structure_config.py index a3dc18556f..e193cc983f 100644 --- a/tests/unit/config/test_google_structure_config.py +++ b/tests/unit/config/test_google_structure_config.py @@ -1,14 +1,14 @@ -from pytest import fixture +import pytest from griptape.config import GoogleStructureConfig class TestGoogleStructureConfig: - @fixture(autouse=True) + @pytest.fixture(autouse=True) def mock_openai(self, mocker): return mocker.patch("google.generativeai.GenerativeModel") - @fixture + @pytest.fixture() def config(self): return GoogleStructureConfig() diff --git a/tests/unit/config/test_openai_structure_config.py b/tests/unit/config/test_openai_structure_config.py index 16fd74aa4f..8969e0ad03 100644 --- a/tests/unit/config/test_openai_structure_config.py +++ b/tests/unit/config/test_openai_structure_config.py @@ -1,14 +1,14 @@ -from pytest import fixture +import pytest from griptape.config import OpenAiStructureConfig class TestOpenAiStructureConfig: - @fixture(autouse=True) + @pytest.fixture(autouse=True) def mock_openai(self, mocker): return mocker.patch("openai.OpenAI") - @fixture + @pytest.fixture() def config(self): return OpenAiStructureConfig() diff --git a/tests/unit/config/test_structure_config.py b/tests/unit/config/test_structure_config.py index 27afa8e6e8..96a68628f2 100644 --- a/tests/unit/config/test_structure_config.py +++ b/tests/unit/config/test_structure_config.py @@ -1,10 +1,10 @@ -from pytest import fixture +import pytest from griptape.config import StructureConfig class TestStructureConfig: - @fixture + @pytest.fixture() def config(self): return StructureConfig() diff --git a/tests/unit/drivers/embedding/test_amazon_bedrock_cohere_embedding_driver.py b/tests/unit/drivers/embedding/test_amazon_bedrock_cohere_embedding_driver.py index 974d8b1434..5644227c96 100644 --- a/tests/unit/drivers/embedding/test_amazon_bedrock_cohere_embedding_driver.py +++ b/tests/unit/drivers/embedding/test_amazon_bedrock_cohere_embedding_driver.py @@ -7,7 +7,7 @@ class TestAmazonBedrockCohereEmbeddingDriver: @pytest.fixture(autouse=True) - def mock_session(self, mocker): + def _mock_session(self, mocker): fake_embeddings = '{"embeddings": [[0, 1, 0]] }' mock_session_class = mocker.patch("boto3.Session") diff --git a/tests/unit/drivers/embedding/test_amazon_bedrock_titan_embedding_driver.py b/tests/unit/drivers/embedding/test_amazon_bedrock_titan_embedding_driver.py index e3005879a8..4470cf62b9 100644 --- a/tests/unit/drivers/embedding/test_amazon_bedrock_titan_embedding_driver.py +++ b/tests/unit/drivers/embedding/test_amazon_bedrock_titan_embedding_driver.py @@ -7,7 +7,7 @@ class TestAmazonBedrockTitanEmbeddingDriver: @pytest.fixture(autouse=True) - def mock_session(self, mocker): + def _mock_session(self, mocker): fake_embeddings = '{"embedding": [0, 1, 0]}' mock_session_class = mocker.patch("boto3.Session") diff --git a/tests/unit/drivers/embedding/test_azure_openai_embedding_driver.py b/tests/unit/drivers/embedding/test_azure_openai_embedding_driver.py index 700434de9c..7f604434b5 100644 --- a/tests/unit/drivers/embedding/test_azure_openai_embedding_driver.py +++ b/tests/unit/drivers/embedding/test_azure_openai_embedding_driver.py @@ -19,7 +19,7 @@ def mock_openai(self, mocker): return mock_chat_create - @pytest.fixture + @pytest.fixture() def driver(self): return AzureOpenAiEmbeddingDriver(azure_endpoint="foobar", model="gpt-4", azure_deployment="foobar") diff --git a/tests/unit/drivers/embedding/test_base_embedding_driver.py b/tests/unit/drivers/embedding/test_base_embedding_driver.py index e65c0946e4..4413468b6d 100644 --- a/tests/unit/drivers/embedding/test_base_embedding_driver.py +++ b/tests/unit/drivers/embedding/test_base_embedding_driver.py @@ -7,7 +7,7 @@ class TestBaseEmbeddingDriver: - @pytest.fixture + @pytest.fixture() def driver(self): return MockEmbeddingDriver() diff --git a/tests/unit/drivers/embedding/test_dummy_embedding_driver.py b/tests/unit/drivers/embedding/test_dummy_embedding_driver.py index 335a14af7c..af56ce6acd 100644 --- a/tests/unit/drivers/embedding/test_dummy_embedding_driver.py +++ b/tests/unit/drivers/embedding/test_dummy_embedding_driver.py @@ -5,7 +5,7 @@ class TestDummyEmbeddingDriver: - @pytest.fixture + @pytest.fixture() def embedding_driver(self): return DummyEmbeddingDriver() diff --git a/tests/unit/drivers/embedding/test_sagemaker_jumpstart_embedding_driver.py b/tests/unit/drivers/embedding/test_sagemaker_jumpstart_embedding_driver.py index 2315dcb0ba..09ec8ec876 100644 --- a/tests/unit/drivers/embedding/test_sagemaker_jumpstart_embedding_driver.py +++ b/tests/unit/drivers/embedding/test_sagemaker_jumpstart_embedding_driver.py @@ -43,19 +43,17 @@ def test_try_embed_chunk(self, mock_client): ).try_embed_chunk("foobar") == [0, 2, 0] mock_client.get().read.return_value = b'{"embedding": []}' - with pytest.raises(ValueError) as e: + with pytest.raises(ValueError, match="model response is empty"): assert AmazonSageMakerJumpstartEmbeddingDriver( endpoint="test-endpoint", model="test-model", tokenizer=OpenAiTokenizer(model=OpenAiTokenizer.DEFAULT_OPENAI_GPT_3_CHAT_MODEL), ).try_embed_chunk("foobar") == [0, 2, 0] - assert str(e) == "model response is empty" mock_client.get().read.return_value = b"{}" - with pytest.raises(ValueError) as e: + with pytest.raises(ValueError, match="invalid response from model"): assert AmazonSageMakerJumpstartEmbeddingDriver( endpoint="test-endpoint", model="test-model", tokenizer=OpenAiTokenizer(model=OpenAiTokenizer.DEFAULT_OPENAI_GPT_3_CHAT_MODEL), ).try_embed_chunk("foobar") == [0, 2, 0] - assert str(e) == "invalid response from model" diff --git a/tests/unit/drivers/event_listener/test_amazon_sqs_event_listener_driver.py b/tests/unit/drivers/event_listener/test_amazon_sqs_event_listener_driver.py index 0513dc1ed0..10ef0354c1 100644 --- a/tests/unit/drivers/event_listener/test_amazon_sqs_event_listener_driver.py +++ b/tests/unit/drivers/event_listener/test_amazon_sqs_event_listener_driver.py @@ -1,6 +1,6 @@ import boto3 +import pytest from moto import mock_sqs -from pytest import fixture from griptape.drivers.event_listener.amazon_sqs_event_listener_driver import AmazonSqsEventListenerDriver from tests.mocks.mock_event import MockEvent @@ -8,11 +8,11 @@ class TestAmazonSqsEventListenerDriver: - @fixture() - def run_before_and_after_tests(self): + @pytest.fixture() + def _run_before_and_after_tests(self): mock_aws_credentials() - @fixture() + @pytest.fixture() def driver(self): mock = mock_sqs() mock.start() diff --git a/tests/unit/drivers/event_listener/test_aws_iot_event_listener_driver.py b/tests/unit/drivers/event_listener/test_aws_iot_event_listener_driver.py index a9c778dff6..b597a5332a 100644 --- a/tests/unit/drivers/event_listener/test_aws_iot_event_listener_driver.py +++ b/tests/unit/drivers/event_listener/test_aws_iot_event_listener_driver.py @@ -1,6 +1,6 @@ import boto3 +import pytest from moto import mock_iotdata -from pytest import fixture from griptape.drivers.event_listener.aws_iot_core_event_listener_driver import AwsIotCoreEventListenerDriver from tests.mocks.mock_event import MockEvent @@ -9,11 +9,11 @@ @mock_iotdata class TestAwsIotCoreEventListenerDriver: - @fixture(autouse=True) - def run_before_and_after_tests(self): + @pytest.fixture(autouse=True) + def _run_before_and_after_tests(self): mock_aws_credentials() - @fixture() + @pytest.fixture() def driver(self): return AwsIotCoreEventListenerDriver( iot_endpoint="foo bar", topic="fizz buzz", session=boto3.Session(region_name="us-east-1") diff --git a/tests/unit/drivers/event_listener/test_griptape_cloud_event_listener_driver.py b/tests/unit/drivers/event_listener/test_griptape_cloud_event_listener_driver.py index d27f09ec8c..b651841ca9 100644 --- a/tests/unit/drivers/event_listener/test_griptape_cloud_event_listener_driver.py +++ b/tests/unit/drivers/event_listener/test_griptape_cloud_event_listener_driver.py @@ -2,14 +2,13 @@ from unittest.mock import Mock import pytest -from pytest import fixture from griptape.drivers.event_listener.griptape_cloud_event_listener_driver import GriptapeCloudEventListenerDriver from tests.mocks.mock_event import MockEvent class TestGriptapeCloudEventListenerDriver: - @fixture(autouse=True) + @pytest.fixture(autouse=True) def mock_post(self, mocker): data = {"data": {"id": "test"}} @@ -18,7 +17,7 @@ def mock_post(self, mocker): return mock_post - @fixture() + @pytest.fixture() def driver(self): os.environ["GT_CLOUD_BASE_URL"] = "https://cloud123.griptape.ai" diff --git a/tests/unit/drivers/event_listener/test_pusher_event_listener_driver.py b/tests/unit/drivers/event_listener/test_pusher_event_listener_driver.py index b14a56324d..50856c0da1 100644 --- a/tests/unit/drivers/event_listener/test_pusher_event_listener_driver.py +++ b/tests/unit/drivers/event_listener/test_pusher_event_listener_driver.py @@ -1,13 +1,13 @@ from unittest.mock import Mock -from pytest import fixture +import pytest from griptape.drivers import PusherEventListenerDriver from tests.mocks.mock_event import MockEvent class TestPusherEventListenerDriver: - @fixture(autouse=True) + @pytest.fixture(autouse=True) def mock_post(self, mocker): mock_pusher_client = mocker.patch("pusher.Pusher") mock_pusher_client.return_value.trigger.return_value = Mock() @@ -15,7 +15,7 @@ def mock_post(self, mocker): return mock_pusher_client - @fixture() + @pytest.fixture() def driver(self): return PusherEventListenerDriver( app_id="test-app-id", diff --git a/tests/unit/drivers/event_listener/test_webhook_event_listener_driver.py b/tests/unit/drivers/event_listener/test_webhook_event_listener_driver.py index 36ace5d43c..f6de0d20f9 100644 --- a/tests/unit/drivers/event_listener/test_webhook_event_listener_driver.py +++ b/tests/unit/drivers/event_listener/test_webhook_event_listener_driver.py @@ -1,13 +1,13 @@ from unittest.mock import Mock -from pytest import fixture +import pytest from griptape.drivers.event_listener.webhook_event_listener_driver import WebhookEventListenerDriver from tests.mocks.mock_event import MockEvent class TestWebhookEventListenerDriver: - @fixture(autouse=True) + @pytest.fixture(autouse=True) def mock_post(self, mocker): mock_post = mocker.patch("requests.post") mock_post.return_value = Mock(status_code=201) diff --git a/tests/unit/drivers/file_manager/test_amazon_s3_file_manager_driver.py b/tests/unit/drivers/file_manager/test_amazon_s3_file_manager_driver.py index f53ff10a31..8914e1891e 100644 --- a/tests/unit/drivers/file_manager/test_amazon_s3_file_manager_driver.py +++ b/tests/unit/drivers/file_manager/test_amazon_s3_file_manager_driver.py @@ -13,19 +13,19 @@ class TestAmazonS3FileManagerDriver: @pytest.fixture(autouse=True) - def set_aws_credentials(self): + def _set_aws_credentials(self): mock_aws_credentials() - @pytest.fixture + @pytest.fixture() def session(self): mock = mock_s3() mock.start() yield boto3.Session(region_name="us-east-1") mock.stop() - @pytest.fixture + @pytest.fixture() def s3_client(self, session): - yield session.client("s3") + return session.client("s3") @pytest.fixture(autouse=True) def bucket(self, s3_client): @@ -60,18 +60,18 @@ def copy_test_resource(resource_path: str) -> None: mkdir("foo/bar-empty") mkdir("foo/bar/baz-empty") - yield bucket + return bucket - @pytest.fixture + @pytest.fixture() def driver(self, session, bucket): return AmazonS3FileManagerDriver(session=session, bucket=bucket) - @pytest.fixture + @pytest.fixture() def temp_dir(self): with tempfile.TemporaryDirectory() as temp_dir: yield temp_dir - @pytest.fixture + @pytest.fixture() def get_s3_value(self, s3_client, bucket): def _get_s3_value(key): return s3_client.get_object(Bucket=bucket, Key=key)["Body"].read().decode() @@ -84,7 +84,7 @@ def test_validate_workdir(self, workdir, session, bucket): AmazonS3FileManagerDriver(session=session, bucket=bucket, workdir=workdir) @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # Valid non-empty directories (without trailing slash) ("/", "", ["foo", "foo.txt", "foo-empty", "resources"]), @@ -132,7 +132,7 @@ def test_list_files(self, workdir, path, expected, driver): assert set(filter(None, artifact.value.split("\n"))) == set(expected) @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # non-existent paths ("/", "bar", "Path not found"), @@ -160,7 +160,7 @@ def test_load_file(self, driver): assert len(artifact.value) == 4 @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # non-existent files or directories ("/", "bitcoin.pdf", "Path not found"), @@ -203,7 +203,7 @@ def test_load_file_with_encoding_failure(self, session, bucket): assert isinstance(artifact, ErrorArtifact) @pytest.mark.parametrize( - "workdir,path,content", + ("workdir", "path", "content"), [ # non-existent files ("/", "resources/foo.txt", "one"), @@ -228,7 +228,7 @@ def test_save_file(self, workdir, path, content, driver, get_s3_value): assert get_s3_value(expected_s3_key) == content_str @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # non-existent directories ("/", "bar/", "Path is a directory"), diff --git a/tests/unit/drivers/file_manager/test_local_file_manager_driver.py b/tests/unit/drivers/file_manager/test_local_file_manager_driver.py index 234bebdf99..ec9963b49c 100644 --- a/tests/unit/drivers/file_manager/test_local_file_manager_driver.py +++ b/tests/unit/drivers/file_manager/test_local_file_manager_driver.py @@ -10,7 +10,7 @@ class TestLocalFileManagerDriver: - @pytest.fixture + @pytest.fixture() def temp_dir(self): with tempfile.TemporaryDirectory() as temp_dir: @@ -48,7 +48,7 @@ def copy_test_resources(resource_path: str) -> None: yield temp_dir - @pytest.fixture + @pytest.fixture() def driver(self, temp_dir): return LocalFileManagerDriver(workdir=temp_dir) @@ -57,7 +57,7 @@ def test_validate_workdir(self): LocalFileManagerDriver(workdir="foo") @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # Valid non-empty directories (without trailing slash) ("/", "", ["foo", "foo.txt", "foo-empty", "resources"]), @@ -106,7 +106,7 @@ def test_list_files(self, workdir, path, expected, temp_dir, driver): assert set(filter(None, artifact.value.split("\n"))) == set(expected) @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # non-existent paths ("/", "bar", "Path not found"), @@ -135,7 +135,7 @@ def test_load_file(self, driver: LocalFileManagerDriver): assert len(artifact.value) == 4 @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # # non-existent files or directories ("/", "bitcoin.pdf", "Path not found"), @@ -179,7 +179,7 @@ def test_load_file_with_encoding_failure(self): assert isinstance(artifact, ErrorArtifact) @pytest.mark.parametrize( - "workdir,path,content", + ("workdir", "path", "content"), [ # non-existent files ("/", "resources/foo.txt", "one"), @@ -204,7 +204,7 @@ def test_save_file(self, workdir, path, content, temp_dir, driver): assert Path(driver.workdir, path).read_text() == content_bytes @pytest.mark.parametrize( - "workdir,path,expected", + ("workdir", "path", "expected"), [ # non-existent directories ("/", "bar/", "Path is a directory"), diff --git a/tests/unit/drivers/image_generation/test_amazon_bedrock_stable_diffusion_image_generation_driver.py b/tests/unit/drivers/image_generation/test_amazon_bedrock_stable_diffusion_image_generation_driver.py index e9e393c343..9aa4d3f4f2 100644 --- a/tests/unit/drivers/image_generation/test_amazon_bedrock_stable_diffusion_image_generation_driver.py +++ b/tests/unit/drivers/image_generation/test_amazon_bedrock_stable_diffusion_image_generation_driver.py @@ -7,18 +7,18 @@ class TestAmazonBedrockImageGenerationDriver: - @pytest.fixture + @pytest.fixture() def bedrock_client(self): return Mock() - @pytest.fixture + @pytest.fixture() def session(self, bedrock_client): session = Mock() session.client.return_value = bedrock_client return session - @pytest.fixture + @pytest.fixture() def model_driver(self): model_driver = Mock() model_driver.text_to_image_request_parameters.return_value = {} @@ -26,7 +26,7 @@ def model_driver(self): return model_driver - @pytest.fixture + @pytest.fixture() def driver(self, session, model_driver): return AmazonBedrockImageGenerationDriver( session=session, model="stability.stable-diffusion-xl-v1", image_generation_model_driver=model_driver diff --git a/tests/unit/drivers/image_generation/test_azure_openai_image_generation_driver.py b/tests/unit/drivers/image_generation/test_azure_openai_image_generation_driver.py index bfc05d0bfb..268708b2b7 100644 --- a/tests/unit/drivers/image_generation/test_azure_openai_image_generation_driver.py +++ b/tests/unit/drivers/image_generation/test_azure_openai_image_generation_driver.py @@ -6,7 +6,7 @@ class TestAzureOpenAiImageGenerationDriver: - @pytest.fixture + @pytest.fixture() def driver(self): return AzureOpenAiImageGenerationDriver( model="dall-e-3", diff --git a/tests/unit/drivers/image_generation/test_dummy_image_generation_driver.py b/tests/unit/drivers/image_generation/test_dummy_image_generation_driver.py index cb9ac7d08e..2df6c64998 100644 --- a/tests/unit/drivers/image_generation/test_dummy_image_generation_driver.py +++ b/tests/unit/drivers/image_generation/test_dummy_image_generation_driver.py @@ -6,7 +6,7 @@ class TestDummyImageGenerationDriver: - @pytest.fixture + @pytest.fixture() def image_generation_driver(self): return DummyImageGenerationDriver() diff --git a/tests/unit/drivers/image_generation/test_leonardo_image_generation_driver.py b/tests/unit/drivers/image_generation/test_leonardo_image_generation_driver.py index 212543d184..48805cde63 100644 --- a/tests/unit/drivers/image_generation/test_leonardo_image_generation_driver.py +++ b/tests/unit/drivers/image_generation/test_leonardo_image_generation_driver.py @@ -7,7 +7,7 @@ class TestLeonardoImageGenerationDriver: - @pytest.fixture + @pytest.fixture() def driver(self): requests_session = Mock() diff --git a/tests/unit/drivers/image_generation/test_openai_image_generation_driver.py b/tests/unit/drivers/image_generation/test_openai_image_generation_driver.py index 466d2bed63..16bcd28701 100644 --- a/tests/unit/drivers/image_generation/test_openai_image_generation_driver.py +++ b/tests/unit/drivers/image_generation/test_openai_image_generation_driver.py @@ -6,7 +6,7 @@ class TestOpenAiImageGenerationDriver: - @pytest.fixture + @pytest.fixture() def driver(self): return OpenAiImageGenerationDriver(model="dall-e-2", client=Mock(), quality="hd", image_size="512x512") diff --git a/tests/unit/drivers/image_generation_model/test_bedrock_stable_diffusion_image_model_driver.py b/tests/unit/drivers/image_generation_model/test_bedrock_stable_diffusion_image_model_driver.py index c43570b88d..60583455ed 100644 --- a/tests/unit/drivers/image_generation_model/test_bedrock_stable_diffusion_image_model_driver.py +++ b/tests/unit/drivers/image_generation_model/test_bedrock_stable_diffusion_image_model_driver.py @@ -7,15 +7,15 @@ class TestBedrockStableDiffusionImageGenerationModelDriver: - @pytest.fixture + @pytest.fixture() def model_driver(self): return BedrockStableDiffusionImageGenerationModelDriver() - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact(b"image", format="png", width=1024, height=1024) - @pytest.fixture + @pytest.fixture() def mask_artifact(self): return ImageArtifact(b"mask", format="png", width=1024, height=1024) diff --git a/tests/unit/drivers/image_generation_model/test_bedrock_titan_image_model_driver.py b/tests/unit/drivers/image_generation_model/test_bedrock_titan_image_model_driver.py index 8c4ed40e30..6bf4c30d5b 100644 --- a/tests/unit/drivers/image_generation_model/test_bedrock_titan_image_model_driver.py +++ b/tests/unit/drivers/image_generation_model/test_bedrock_titan_image_model_driver.py @@ -5,15 +5,15 @@ class TestBedrockTitanImageGenerationModelDriver: - @pytest.fixture + @pytest.fixture() def model_driver(self): return BedrockTitanImageGenerationModelDriver() - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact(b"image", format="png", width=1024, height=512) - @pytest.fixture + @pytest.fixture() def mask_artifact(self): return ImageArtifact(b"mask", format="png", width=1024, height=512) diff --git a/tests/unit/drivers/image_query/test_amazon_bedrock_image_query_driver.py b/tests/unit/drivers/image_query/test_amazon_bedrock_image_query_driver.py index c4a4ea60d3..9493ab23de 100644 --- a/tests/unit/drivers/image_query/test_amazon_bedrock_image_query_driver.py +++ b/tests/unit/drivers/image_query/test_amazon_bedrock_image_query_driver.py @@ -8,18 +8,18 @@ class TestAmazonBedrockImageQueryDriver: - @pytest.fixture + @pytest.fixture() def bedrock_client(self, mocker): return Mock() - @pytest.fixture + @pytest.fixture() def session(self, bedrock_client): session = Mock() session.client.return_value = bedrock_client return session - @pytest.fixture + @pytest.fixture() def model_driver(self): model_driver = Mock() model_driver.image_query_request_parameters.return_value = {} @@ -27,7 +27,7 @@ def model_driver(self): return model_driver - @pytest.fixture + @pytest.fixture() def image_query_driver(self, session, model_driver): return AmazonBedrockImageQueryDriver(session=session, model="model", image_query_model_driver=model_driver) diff --git a/tests/unit/drivers/image_query/test_anthropic_image_query_driver.py b/tests/unit/drivers/image_query/test_anthropic_image_query_driver.py index 65cf1e3b49..db4b2407cf 100644 --- a/tests/unit/drivers/image_query/test_anthropic_image_query_driver.py +++ b/tests/unit/drivers/image_query/test_anthropic_image_query_driver.py @@ -8,7 +8,7 @@ class TestAnthropicImageQueryDriver: - @pytest.fixture + @pytest.fixture() def mock_client(self, mocker): mock_client = mocker.patch("anthropic.Anthropic") return_value = Mock(text="Content") diff --git a/tests/unit/drivers/image_query/test_azure_openai_image_query_driver.py b/tests/unit/drivers/image_query/test_azure_openai_image_query_driver.py index e18e0f1b82..a1d428197f 100644 --- a/tests/unit/drivers/image_query/test_azure_openai_image_query_driver.py +++ b/tests/unit/drivers/image_query/test_azure_openai_image_query_driver.py @@ -7,7 +7,7 @@ class TestAzureOpenAiVisionImageQueryDriver: - @pytest.fixture + @pytest.fixture() def mock_completion_create(self, mocker): mock_chat_create = mocker.patch("openai.AzureOpenAI").return_value.chat.completions.create mock_choice = Mock(message=Mock(content="expected_output_text")) diff --git a/tests/unit/drivers/image_query/test_dummy_image_query_driver.py b/tests/unit/drivers/image_query/test_dummy_image_query_driver.py index dedd8cb393..02b69595f3 100644 --- a/tests/unit/drivers/image_query/test_dummy_image_query_driver.py +++ b/tests/unit/drivers/image_query/test_dummy_image_query_driver.py @@ -6,7 +6,7 @@ class TestDummyImageQueryDriver: - @pytest.fixture + @pytest.fixture() def image_query_driver(self): return DummyImageQueryDriver() diff --git a/tests/unit/drivers/image_query/test_openai_image_query_driver.py b/tests/unit/drivers/image_query/test_openai_image_query_driver.py index 36177dc00a..9c4b011a6f 100644 --- a/tests/unit/drivers/image_query/test_openai_image_query_driver.py +++ b/tests/unit/drivers/image_query/test_openai_image_query_driver.py @@ -7,7 +7,7 @@ class TestOpenAiVisionImageQueryDriver: - @pytest.fixture + @pytest.fixture() def mock_completion_create(self, mocker): mock_chat_create = mocker.patch("openai.OpenAI").return_value.chat.completions.create mock_choice = Mock(message=Mock(content="expected_output_text")) diff --git a/tests/unit/drivers/memory/conversation/test_dynamodb_conversation_memory_driver.py b/tests/unit/drivers/memory/conversation/test_dynamodb_conversation_memory_driver.py index 1b4f2c303f..8e700d0a56 100644 --- a/tests/unit/drivers/memory/conversation/test_dynamodb_conversation_memory_driver.py +++ b/tests/unit/drivers/memory/conversation/test_dynamodb_conversation_memory_driver.py @@ -18,7 +18,7 @@ class TestDynamoDbConversationMemoryDriver: PARTITION_KEY_VALUE = "bar" @pytest.fixture(autouse=True) - def run_before_and_after_tests(self): + def _run_before_and_after_tests(self): mock_aws_credentials() self.mock_dynamodb = mock_dynamodb() self.mock_dynamodb.start() diff --git a/tests/unit/drivers/memory/conversation/test_local_conversation_memory_driver.py b/tests/unit/drivers/memory/conversation/test_local_conversation_memory_driver.py index 59d3f00b43..e1a383ab9e 100644 --- a/tests/unit/drivers/memory/conversation/test_local_conversation_memory_driver.py +++ b/tests/unit/drivers/memory/conversation/test_local_conversation_memory_driver.py @@ -14,7 +14,7 @@ class TestLocalConversationMemoryDriver: MEMORY_FILE_PATH = "test_memory.json" @pytest.fixture(autouse=True) - def run_before_and_after_tests(self): + def _run_before_and_after_tests(self): self.__delete_file(self.MEMORY_FILE_PATH) yield diff --git a/tests/unit/drivers/memory/conversation/test_redis_conversation_memory_driver.py b/tests/unit/drivers/memory/conversation/test_redis_conversation_memory_driver.py index 6cc255a3fc..4a92a28a80 100644 --- a/tests/unit/drivers/memory/conversation/test_redis_conversation_memory_driver.py +++ b/tests/unit/drivers/memory/conversation/test_redis_conversation_memory_driver.py @@ -14,7 +14,7 @@ class TestRedisConversationMemoryDriver: @pytest.fixture(autouse=True) - def mock_redis(self, mocker): + def _mock_redis(self, mocker): mocker.patch.object(redis.StrictRedis, "hset", return_value=None) mocker.patch.object(redis.StrictRedis, "keys", return_value=[b"test"]) mocker.patch.object(redis.StrictRedis, "hget", return_value=TEST_CONVERSATION) @@ -26,7 +26,7 @@ def mock_redis(self, mocker): mocker.patch.object(redis.StrictRedis, "ft", return_value=fake_redisearch) - @pytest.fixture + @pytest.fixture() def driver(self): return RedisConversationMemoryDriver(host=HOST, port=PORT, db=0, index=INDEX, conversation_id=CONVERSATION_ID) diff --git a/tests/unit/drivers/prompt/test_amazon_bedrock_prompt_driver.py b/tests/unit/drivers/prompt/test_amazon_bedrock_prompt_driver.py index fa3c250f81..6a58b09dcc 100644 --- a/tests/unit/drivers/prompt/test_amazon_bedrock_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_amazon_bedrock_prompt_driver.py @@ -157,7 +157,7 @@ class TestAmazonBedrockPromptDriver: }, ] - @pytest.fixture + @pytest.fixture() def mock_converse(self, mocker): mock_converse = mocker.patch("boto3.Session").return_value.client.return_value.converse @@ -175,7 +175,7 @@ def mock_converse(self, mocker): return mock_converse - @pytest.fixture + @pytest.fixture() def mock_converse_stream(self, mocker): mock_converse_stream = mocker.patch("boto3.Session").return_value.client.return_value.converse_stream @@ -273,7 +273,7 @@ def prompt_stack(self, request): return prompt_stack - @pytest.fixture + @pytest.fixture() def messages(self): return [ {"role": "user", "content": [{"text": "user-input"}]}, diff --git a/tests/unit/drivers/prompt/test_anthropic_prompt_driver.py b/tests/unit/drivers/prompt/test_anthropic_prompt_driver.py index d5fb0f710a..3b1343336d 100644 --- a/tests/unit/drivers/prompt/test_anthropic_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_anthropic_prompt_driver.py @@ -132,7 +132,7 @@ class TestAnthropicPromptDriver: }, ] - @pytest.fixture + @pytest.fixture() def mock_client(self, mocker): mock_client = mocker.patch("anthropic.Anthropic") mock_tool_use = Mock(type="tool_use", id="mock-id", input={"foo": "bar"}) @@ -151,7 +151,7 @@ def mock_client(self, mocker): return mock_client - @pytest.fixture + @pytest.fixture() def mock_stream_client(self, mocker): mock_stream_client = mocker.patch("anthropic.Anthropic") @@ -264,7 +264,7 @@ def prompt_stack(self, request): return prompt_stack - @pytest.fixture + @pytest.fixture() def messages(self): return [ {"role": "user", "content": "user-input"}, diff --git a/tests/unit/drivers/prompt/test_azure_openai_chat_prompt_driver.py b/tests/unit/drivers/prompt/test_azure_openai_chat_prompt_driver.py index aa4e991132..dc0b54b0a2 100644 --- a/tests/unit/drivers/prompt/test_azure_openai_chat_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_azure_openai_chat_prompt_driver.py @@ -9,7 +9,7 @@ class TestAzureOpenAiChatPromptDriver(TestOpenAiChatPromptDriverFixtureMixin): - @pytest.fixture + @pytest.fixture() def mock_chat_completion_create(self, mocker): mock_chat_create = mocker.patch("openai.AzureOpenAI").return_value.chat.completions.create mock_function = Mock(arguments='{"foo": "bar"}', id="mock-id") @@ -24,7 +24,7 @@ def mock_chat_completion_create(self, mocker): return mock_chat_create - @pytest.fixture + @pytest.fixture() def mock_chat_completion_stream_create(self, mocker): mock_chat_create = mocker.patch("openai.AzureOpenAI").return_value.chat.completions.create mock_tool_call_delta_header = Mock() diff --git a/tests/unit/drivers/prompt/test_cohere_prompt_driver.py b/tests/unit/drivers/prompt/test_cohere_prompt_driver.py index 197e35e840..c642b7ee00 100644 --- a/tests/unit/drivers/prompt/test_cohere_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_cohere_prompt_driver.py @@ -41,7 +41,7 @@ class TestCoherePromptDriver: }, ] - @pytest.fixture + @pytest.fixture() def mock_client(self, mocker): mock_client = mocker.patch("cohere.Client").return_value mock_tool_call = Mock(parameters={"foo": "bar"}) @@ -52,7 +52,7 @@ def mock_client(self, mocker): return mock_client - @pytest.fixture + @pytest.fixture() def mock_stream_client(self, mocker): mock_client = mocker.patch("cohere.Client").return_value mock_tool_call_delta_header = Mock() diff --git a/tests/unit/drivers/prompt/test_dummy_prompt_driver.py b/tests/unit/drivers/prompt/test_dummy_prompt_driver.py index 8b2a966c0f..203bad3d51 100644 --- a/tests/unit/drivers/prompt/test_dummy_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_dummy_prompt_driver.py @@ -5,7 +5,7 @@ class TestDummyPromptDriver: - @pytest.fixture + @pytest.fixture() def prompt_driver(self): return DummyPromptDriver() diff --git a/tests/unit/drivers/prompt/test_google_prompt_driver.py b/tests/unit/drivers/prompt/test_google_prompt_driver.py index 5770f153f7..478ef8fb9c 100644 --- a/tests/unit/drivers/prompt/test_google_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_google_prompt_driver.py @@ -43,7 +43,7 @@ class TestGooglePromptDriver: }, ] - @pytest.fixture + @pytest.fixture() def mock_generative_model(self, mocker): mock_generative_model = mocker.patch("google.generativeai.GenerativeModel") mock_function_call = Mock(type="tool_use", id="MockTool_test", args={"foo": "bar"}) @@ -55,7 +55,7 @@ def mock_generative_model(self, mocker): return mock_generative_model - @pytest.fixture + @pytest.fixture() def mock_stream_generative_model(self, mocker): mock_generative_model = mocker.patch("google.generativeai.GenerativeModel") mock_function_call_delta = Mock(type="tool_use", id="MockTool_test", args={"foo": "bar"}) @@ -117,7 +117,7 @@ def prompt_stack(self, request): return prompt_stack - @pytest.fixture + @pytest.fixture() def messages(self): return [ {"parts": ["user-input"], "role": "user"}, diff --git a/tests/unit/drivers/prompt/test_hugging_face_hub_prompt_driver.py b/tests/unit/drivers/prompt/test_hugging_face_hub_prompt_driver.py index 96e9cf1a11..1a4e1b25bd 100644 --- a/tests/unit/drivers/prompt/test_hugging_face_hub_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_hugging_face_hub_prompt_driver.py @@ -5,7 +5,7 @@ class TestHuggingFaceHubPromptDriver: - @pytest.fixture + @pytest.fixture() def mock_client(self, mocker): mock_client = mocker.patch("huggingface_hub.InferenceClient").return_value @@ -21,14 +21,14 @@ def tokenizer(self, mocker): return tokenizer - @pytest.fixture + @pytest.fixture() def mock_client_stream(self, mocker): mock_client = mocker.patch("huggingface_hub.InferenceClient").return_value mock_client.text_generation.return_value = iter(["model-output"]) return mock_client - @pytest.fixture + @pytest.fixture() def prompt_stack(self): prompt_stack = PromptStack() prompt_stack.add_system_message("system-input") diff --git a/tests/unit/drivers/prompt/test_hugging_face_pipeline_prompt_driver.py b/tests/unit/drivers/prompt/test_hugging_face_pipeline_prompt_driver.py index 90e3e459db..5323f5d2d7 100644 --- a/tests/unit/drivers/prompt/test_hugging_face_pipeline_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_hugging_face_pipeline_prompt_driver.py @@ -26,7 +26,7 @@ def mock_autotokenizer(self, mocker): mock_autotokenizer.encode.return_value = [1, 2, 3] return mock_autotokenizer - @pytest.fixture + @pytest.fixture() def prompt_stack(self): prompt_stack = PromptStack() prompt_stack.add_system_message("system-input") diff --git a/tests/unit/drivers/prompt/test_ollama_prompt_driver.py b/tests/unit/drivers/prompt/test_ollama_prompt_driver.py index 7c02c860f9..e51da368a2 100644 --- a/tests/unit/drivers/prompt/test_ollama_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_ollama_prompt_driver.py @@ -7,7 +7,7 @@ class TestOllamaPromptDriver: - @pytest.fixture + @pytest.fixture() def mock_client(self, mocker): mock_client = mocker.patch("ollama.Client") @@ -15,7 +15,7 @@ def mock_client(self, mocker): return mock_client - @pytest.fixture + @pytest.fixture() def mock_stream_client(self, mocker): mock_stream_client = mocker.patch("ollama.Client") mock_stream_client.return_value.chat.return_value = iter([{"message": {"content": "model-output"}}]) diff --git a/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py b/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py index 7bc778a329..23a40e20ca 100644 --- a/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py @@ -154,7 +154,7 @@ class TestOpenAiChatPromptDriverFixtureMixin: }, ] - @pytest.fixture + @pytest.fixture() def mock_chat_completion_create(self, mocker): mock_chat_create = mocker.patch("openai.OpenAI").return_value.chat.completions.create mock_function = Mock(arguments='{"foo": "bar"}', id="mock-id") @@ -169,7 +169,7 @@ def mock_chat_completion_create(self, mocker): return mock_chat_create - @pytest.fixture + @pytest.fixture() def mock_chat_completion_stream_create(self, mocker): mock_chat_create = mocker.patch("openai.OpenAI").return_value.chat.completions.create mock_tool_call_delta_header = Mock() @@ -207,7 +207,7 @@ def mock_chat_completion_stream_create(self, mocker): ) return mock_chat_create - @pytest.fixture + @pytest.fixture() def prompt_stack(self): prompt_stack = PromptStack() prompt_stack.tools = [MockTool()] @@ -245,7 +245,7 @@ def prompt_stack(self): ) return prompt_stack - @pytest.fixture + @pytest.fixture() def messages(self): return [ {"role": "system", "content": "system-input"}, diff --git a/tests/unit/drivers/rerank/test_cohere_rerank_driver.py b/tests/unit/drivers/rerank/test_cohere_rerank_driver.py index c5a6eb4c21..87a727269a 100644 --- a/tests/unit/drivers/rerank/test_cohere_rerank_driver.py +++ b/tests/unit/drivers/rerank/test_cohere_rerank_driver.py @@ -6,7 +6,7 @@ class TestCohereRerankDriver: - @pytest.fixture + @pytest.fixture() def mock_client(self, mocker): mock_client = mocker.patch("cohere.Client").return_value mock_client.rerank.return_value.results = [ diff --git a/tests/unit/drivers/sql/test_amazon_redshift_sql_driver.py b/tests/unit/drivers/sql/test_amazon_redshift_sql_driver.py index 24cf8fd3c4..966df481c8 100644 --- a/tests/unit/drivers/sql/test_amazon_redshift_sql_driver.py +++ b/tests/unit/drivers/sql/test_amazon_redshift_sql_driver.py @@ -42,7 +42,7 @@ class TestAmazonRedshiftSqlDriver: }, ] - @pytest.fixture + @pytest.fixture() def statement_driver(self): session = boto3.Session(region_name="us-east-1") client = session.client("redshift-data") @@ -109,7 +109,7 @@ def statement_driver(self): return AmazonRedshiftSqlDriver(database="dev", session=session, workgroup_name="dev", client=client) - @pytest.fixture + @pytest.fixture() def describe_table_driver(self): session = boto3.Session(region_name="us-east-1") client = session.client("redshift-data") diff --git a/tests/unit/drivers/sql/test_snowflake_sql_driver.py b/tests/unit/drivers/sql/test_snowflake_sql_driver.py index 818eed7ec0..055b1e7444 100644 --- a/tests/unit/drivers/sql/test_snowflake_sql_driver.py +++ b/tests/unit/drivers/sql/test_snowflake_sql_driver.py @@ -13,7 +13,7 @@ class TestSnowflakeSqlDriver: TEST_COLUMNS = [("first_name", "VARCHAR"), ("last_name", "VARCHAR")] - @pytest.fixture + @pytest.fixture() def mock_table(self, mocker): @dataclass class Column: @@ -23,13 +23,13 @@ class Column: mock_table = mocker.MagicMock(name="table", columns=[Column("first_name"), Column("last_name")]) return mock_table - @pytest.fixture + @pytest.fixture() def mock_metadata(self, mocker): mock_meta = mocker.MagicMock(name="metadata") mock_meta.reflect.return_value = None return mock_meta - @pytest.fixture + @pytest.fixture() def mock_snowflake_engine(self, mocker): mock_engine = mocker.MagicMock(name="engine") result_mock = mocker.MagicMock(name="result") @@ -46,22 +46,22 @@ def mock_snowflake_engine(self, mocker): return mock_engine - @pytest.fixture + @pytest.fixture() def mock_snowflake_connection(self, mocker): mock_connection = mocker.MagicMock(spec=SnowflakeConnection, name="connection") return mock_connection - @pytest.fixture + @pytest.fixture() def mock_snowflake_connection_no_schema(self, mocker): mock_connection = mocker.MagicMock(spec=SnowflakeConnection, name="connection_no_schema", schema=None) return mock_connection - @pytest.fixture + @pytest.fixture() def mock_snowflake_connection_no_database(self, mocker): mock_connection = mocker.MagicMock(spec=SnowflakeConnection, name="connection_no_database", database=None) return mock_connection - @pytest.fixture + @pytest.fixture() def driver(self, mock_snowflake_engine, mock_snowflake_connection): def get_connection(): return mock_snowflake_connection diff --git a/tests/unit/drivers/sql/test_sql_driver.py b/tests/unit/drivers/sql/test_sql_driver.py index 46e07752c8..742acd0b26 100644 --- a/tests/unit/drivers/sql/test_sql_driver.py +++ b/tests/unit/drivers/sql/test_sql_driver.py @@ -4,7 +4,7 @@ class TestSqlDriver: - @pytest.fixture + @pytest.fixture() def driver(self): new_driver = SqlDriver(engine_url="sqlite:///:memory:") diff --git a/tests/unit/drivers/structure_run/test_griptape_cloud_structure_run_driver.py b/tests/unit/drivers/structure_run/test_griptape_cloud_structure_run_driver.py index ffc6374a3c..bdd5cd3ed4 100644 --- a/tests/unit/drivers/structure_run/test_griptape_cloud_structure_run_driver.py +++ b/tests/unit/drivers/structure_run/test_griptape_cloud_structure_run_driver.py @@ -4,7 +4,7 @@ class TestGriptapeCloudStructureRunDriver: - @pytest.fixture + @pytest.fixture() def driver(self, mocker): from griptape.drivers import GriptapeCloudStructureRunDriver diff --git a/tests/unit/drivers/text_to_speech/test_elevenlabs_audio_generation_driver.py b/tests/unit/drivers/text_to_speech/test_elevenlabs_audio_generation_driver.py index 68786bd2e3..26c29adcfa 100644 --- a/tests/unit/drivers/text_to_speech/test_elevenlabs_audio_generation_driver.py +++ b/tests/unit/drivers/text_to_speech/test_elevenlabs_audio_generation_driver.py @@ -6,7 +6,7 @@ class TestElevenLabsTextToSpeechDriver: - @pytest.fixture + @pytest.fixture() def driver(self): return ElevenLabsTextToSpeechDriver(model="model", client=Mock(), voice="voice", api_key="key") diff --git a/tests/unit/drivers/transcription/test_openai_audio_transcription_driver.py b/tests/unit/drivers/transcription/test_openai_audio_transcription_driver.py index 90e7d95240..f9c22a7259 100644 --- a/tests/unit/drivers/transcription/test_openai_audio_transcription_driver.py +++ b/tests/unit/drivers/transcription/test_openai_audio_transcription_driver.py @@ -7,11 +7,11 @@ class TestOpenAiAudioTranscriptionDriver: - @pytest.fixture + @pytest.fixture() def audio_artifact(self): return AudioArtifact(value=b"audio data", format="mp3") - @pytest.fixture + @pytest.fixture() def driver(self): return OpenAiAudioTranscriptionDriver(model="model", client=Mock(), api_key="key") diff --git a/tests/unit/drivers/vector/test_amazon_opensearch_vector_store_driver.py b/tests/unit/drivers/vector/test_amazon_opensearch_vector_store_driver.py index e0ae3329fe..e5988b234a 100644 --- a/tests/unit/drivers/vector/test_amazon_opensearch_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_amazon_opensearch_vector_store_driver.py @@ -8,7 +8,7 @@ class TestAmazonOpenSearchVectorStoreDriver: - @pytest.fixture + @pytest.fixture() def driver(self): mock_session = create_autospec(boto3.Session, instance=True) mock_driver = create_autospec(AmazonOpenSearchVectorStoreDriver, instance=True, session=mock_session) diff --git a/tests/unit/drivers/vector/test_azure_mongodb_vector_store_driver.py b/tests/unit/drivers/vector/test_azure_mongodb_vector_store_driver.py index 03f9a89bf4..6dd4fa5e94 100644 --- a/tests/unit/drivers/vector/test_azure_mongodb_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_azure_mongodb_vector_store_driver.py @@ -7,7 +7,7 @@ class TestAzureMongoDbVectorStoreDriver: - @pytest.fixture + @pytest.fixture() def driver(self, monkeypatch): embedding_driver = MockEmbeddingDriver() return AzureMongoDbVectorStoreDriver( @@ -65,15 +65,18 @@ def test_load_entries(self, driver): vector = [0.5, 0.5, 0.5] driver.upsert_vector(vector, vector_id=vector_id_str) # ensure at least one entry exists results = list(driver.load_entries()) - assert results is not None and len(results) > 0 + assert results is not None + assert len(results) > 0 def test_delete(self, driver): vector_id_str = "123" vector = [0.5, 0.5, 0.5] driver.upsert_vector(vector, vector_id=vector_id_str) # ensure at least one entry exists results = list(driver.load_entries()) - assert results is not None and len(results) > 0 + assert results is not None + assert len(results) > 0 driver.delete_vector(vector_id_str) results = list(driver.load_entries()) - assert results is not None and len(results) == 0 + assert results is not None + assert len(results) == 0 diff --git a/tests/unit/drivers/vector/test_base_local_vector_store_driver.py b/tests/unit/drivers/vector/test_base_local_vector_store_driver.py index 674c3ffb9a..a452c538cf 100644 --- a/tests/unit/drivers/vector/test_base_local_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_base_local_vector_store_driver.py @@ -8,7 +8,7 @@ class BaseLocalVectorStoreDriver(ABC): - @pytest.fixture + @pytest.fixture() @abstractmethod def driver(self): ... diff --git a/tests/unit/drivers/vector/test_dummy_vector_store_driver.py b/tests/unit/drivers/vector/test_dummy_vector_store_driver.py index fcc144f8d1..53ac2a27c0 100644 --- a/tests/unit/drivers/vector/test_dummy_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_dummy_vector_store_driver.py @@ -5,7 +5,7 @@ class TestDummyVectorStoreDriver: - @pytest.fixture + @pytest.fixture() def vector_store_driver(self): return DummyVectorStoreDriver() diff --git a/tests/unit/drivers/vector/test_griptape_cloud_knowledge_base_vector_store_driver.py b/tests/unit/drivers/vector/test_griptape_cloud_knowledge_base_vector_store_driver.py index 19d0f5cdca..0f52ba6c56 100644 --- a/tests/unit/drivers/vector/test_griptape_cloud_knowledge_base_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_griptape_cloud_knowledge_base_vector_store_driver.py @@ -12,7 +12,7 @@ class TestGriptapeCloudKnowledgeBaseVectorStoreDriver: test_metas = [{"key": "value1"}, {"key": "value2"}] test_scores = [0.7, 0.8] - @pytest.fixture + @pytest.fixture() def driver(self, mocker): test_entries = { "entries": [ diff --git a/tests/unit/drivers/vector/test_local_vector_store_driver.py b/tests/unit/drivers/vector/test_local_vector_store_driver.py index 3612364e4d..cecdc80a99 100644 --- a/tests/unit/drivers/vector/test_local_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_local_vector_store_driver.py @@ -7,7 +7,7 @@ class TestLocalVectorStoreDriver(BaseLocalVectorStoreDriver): - @pytest.fixture + @pytest.fixture() def driver(self): return LocalVectorStoreDriver(embedding_driver=MockEmbeddingDriver()) diff --git a/tests/unit/drivers/vector/test_marqo_vector_store_driver.py b/tests/unit/drivers/vector/test_marqo_vector_store_driver.py index a0e0dc072a..5c2399bc5e 100644 --- a/tests/unit/drivers/vector/test_marqo_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_marqo_vector_store_driver.py @@ -81,7 +81,7 @@ def mock_marqo(self, mocker): # Return the mock_client for use in other fixtures return mock_client - @pytest.fixture + @pytest.fixture() def driver(self, mock_marqo): return MarqoVectorStoreDriver( api_key="foobar", diff --git a/tests/unit/drivers/vector/test_mongodb_atlas_vector_store_driver.py b/tests/unit/drivers/vector/test_mongodb_atlas_vector_store_driver.py index 39e59f1e2c..20cb8bdc00 100644 --- a/tests/unit/drivers/vector/test_mongodb_atlas_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_mongodb_atlas_vector_store_driver.py @@ -7,7 +7,7 @@ class TestMongoDbAtlasVectorStoreDriver: - @pytest.fixture + @pytest.fixture() def driver(self, monkeypatch): embedding_driver = MockEmbeddingDriver() return MongoDbAtlasVectorStoreDriver( @@ -65,15 +65,18 @@ def test_load_entries(self, driver): vector = [0.5, 0.5, 0.5] driver.upsert_vector(vector, vector_id=vector_id_str) # ensure at least one entry exists results = list(driver.load_entries()) - assert results is not None and len(results) > 0 + assert results is not None + assert len(results) > 0 def test_delete(self, driver): vector_id_str = "123" vector = [0.5, 0.5, 0.5] driver.upsert_vector(vector, vector_id=vector_id_str) # ensure at least one entry exists results = list(driver.load_entries()) - assert results is not None and len(results) > 0 + assert results is not None + assert len(results) > 0 driver.delete_vector(vector_id_str) results = list(driver.load_entries()) - assert results is not None and len(results) == 0 + assert results is not None + assert len(results) == 0 diff --git a/tests/unit/drivers/vector/test_opensearch_vector_store_driver.py b/tests/unit/drivers/vector/test_opensearch_vector_store_driver.py index a010ae72cf..cef3805ab6 100644 --- a/tests/unit/drivers/vector/test_opensearch_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_opensearch_vector_store_driver.py @@ -7,7 +7,7 @@ class TestOpenSearchVectorStoreDriver: - @pytest.fixture + @pytest.fixture() def driver(self): mock_driver = create_autospec(OpenSearchVectorStoreDriver, instance=True) mock_driver.upsert_vector.return_value = "foo" diff --git a/tests/unit/drivers/vector/test_persistent_local_vector_store_driver.py b/tests/unit/drivers/vector/test_persistent_local_vector_store_driver.py index 0c0f592e8f..c130858b55 100644 --- a/tests/unit/drivers/vector/test_persistent_local_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_persistent_local_vector_store_driver.py @@ -10,12 +10,12 @@ class TestPersistentLocalVectorStoreDriver(BaseLocalVectorStoreDriver): - @pytest.fixture + @pytest.fixture() def temp_dir(self): with tempfile.TemporaryDirectory() as temp_dir: yield temp_dir - @pytest.fixture + @pytest.fixture() def driver(self, temp_dir): persist_file = os.path.join(temp_dir, "store.json") diff --git a/tests/unit/drivers/vector/test_pgvector_vector_store_driver.py b/tests/unit/drivers/vector/test_pgvector_vector_store_driver.py index be0b954e2b..29b5ad82e4 100644 --- a/tests/unit/drivers/vector/test_pgvector_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_pgvector_vector_store_driver.py @@ -13,15 +13,15 @@ class TestPgVectorVectorStoreDriver: connection_string = "postgresql://postgres:postgres@localhost:5432/postgres" table_name = "griptape_vectors" - @pytest.fixture + @pytest.fixture() def embedding_driver(self): return MockEmbeddingDriver() - @pytest.fixture + @pytest.fixture() def mock_engine(self): return MagicMock() - @pytest.fixture + @pytest.fixture() def mock_session(self, mocker): session = MagicMock() mock_session_manager = MagicMock() diff --git a/tests/unit/drivers/vector/test_pinecone_vector_storage_driver.py b/tests/unit/drivers/vector/test_pinecone_vector_storage_driver.py index 58bfde062e..0726a0c7ea 100644 --- a/tests/unit/drivers/vector/test_pinecone_vector_storage_driver.py +++ b/tests/unit/drivers/vector/test_pinecone_vector_storage_driver.py @@ -7,7 +7,7 @@ class TestPineconeVectorStorageDriver: @pytest.fixture(autouse=True) - def mock_pinecone(self, mocker): + def _mock_pinecone(self, mocker): # Create a fake response fake_query_response = { "matches": [{"id": "foo", "values": [0, 1, 0], "score": 42, "metadata": {"foo": "bar"}}], @@ -19,7 +19,7 @@ def mock_pinecone(self, mocker): mock_client().Index().query.return_value = fake_query_response mock_client().create_index.return_value = None - @pytest.fixture + @pytest.fixture() def driver(self): return PineconeVectorStoreDriver( api_key="foobar", index_name="test", environment="test", embedding_driver=MockEmbeddingDriver() diff --git a/tests/unit/drivers/vector/test_qdrant_vector_store_driver.py b/tests/unit/drivers/vector/test_qdrant_vector_store_driver.py index 8ba6dc2307..ea815b34e4 100644 --- a/tests/unit/drivers/vector/test_qdrant_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_qdrant_vector_store_driver.py @@ -9,11 +9,11 @@ class TestQdrantVectorStoreDriver: - @pytest.fixture + @pytest.fixture() def embedding_driver(self): return MockEmbeddingDriver() - @pytest.fixture + @pytest.fixture() def mock_engine(self): return MagicMock() diff --git a/tests/unit/drivers/vector/test_redis_vector_store_driver.py b/tests/unit/drivers/vector/test_redis_vector_store_driver.py index 9db5f116cb..2f74b9279d 100644 --- a/tests/unit/drivers/vector/test_redis_vector_store_driver.py +++ b/tests/unit/drivers/vector/test_redis_vector_store_driver.py @@ -11,12 +11,12 @@ class TestRedisVectorStorageDriver: def mock_client(self, mocker): return mocker.patch("redis.Redis").return_value - @pytest.fixture + @pytest.fixture() def mock_keys(self, mock_client): mock_client.keys.return_value = [b"some_vector_id"] return mock_client.keys - @pytest.fixture + @pytest.fixture() def mock_hgetall(self, mock_client): mock_client.hgetall.return_value = { b"vector": b"\x00\x00\x80?\x00\x00\x00@\x00\x00@@", @@ -24,13 +24,13 @@ def mock_hgetall(self, mock_client): } return mock_client.hgetall - @pytest.fixture + @pytest.fixture() def driver(self): return RedisVectorStoreDriver( host="localhost", port=6379, index="test_index", db=0, embedding_driver=MockEmbeddingDriver() ) - @pytest.fixture + @pytest.fixture() def mock_search(self, mock_client): mock_client.ft.return_value.search.return_value.docs = [ MagicMock( diff --git a/tests/unit/drivers/web_scraper/test_markdownify_web_scraper_driver.py b/tests/unit/drivers/web_scraper/test_markdownify_web_scraper_driver.py index c9dbae4a8f..dbdafa98f5 100644 --- a/tests/unit/drivers/web_scraper/test_markdownify_web_scraper_driver.py +++ b/tests/unit/drivers/web_scraper/test_markdownify_web_scraper_driver.py @@ -16,7 +16,7 @@ def mock_content(self, mock_playwright): mock_content.return_value = 'foobar' return mock_content - @pytest.fixture + @pytest.fixture() def web_scraper(self): return MarkdownifyWebScraperDriver() diff --git a/tests/unit/drivers/web_scraper/test_proxy_web_scraper_driver.py b/tests/unit/drivers/web_scraper/test_proxy_web_scraper_driver.py index 0cc61d39db..95e5a2880a 100644 --- a/tests/unit/drivers/web_scraper/test_proxy_web_scraper_driver.py +++ b/tests/unit/drivers/web_scraper/test_proxy_web_scraper_driver.py @@ -11,11 +11,11 @@ def mock_client(self, mocker): mock_response.text = "test_scrape" return mocker.patch("requests.get", return_value=mock_response) - @pytest.fixture + @pytest.fixture() def mock_client_error(self, mocker): return mocker.patch("requests.get", side_effect=Exception("test_error")) - @pytest.fixture + @pytest.fixture() def web_scraper(self, mocker): return ProxyWebScraperDriver( proxies={"http": "http://localhost:8080", "https": "http://localhost:8080"}, diff --git a/tests/unit/drivers/web_scraper/test_trafilatura_web_scraper_driver.py b/tests/unit/drivers/web_scraper/test_trafilatura_web_scraper_driver.py index f2ea56666b..53ddf4500c 100644 --- a/tests/unit/drivers/web_scraper/test_trafilatura_web_scraper_driver.py +++ b/tests/unit/drivers/web_scraper/test_trafilatura_web_scraper_driver.py @@ -5,7 +5,7 @@ class TestTrafilaturaWebScraperDriver: @pytest.fixture(autouse=True) - def mock_fetch_url(self, mocker): + def _mock_fetch_url(self, mocker): # Through trial and error, I've found that include_links in trafilatura's extract does not work # if the body of the page is not long enough, which is why I'm adding an arbitrary number of # characters to the body. @@ -13,7 +13,7 @@ def mock_fetch_url(self, mocker): "trafilatura.fetch_url" ).return_value = f'{"x"*243}foobar' - @pytest.fixture + @pytest.fixture() def web_scraper(self): return TrafilaturaWebScraperDriver(include_links=True) diff --git a/tests/unit/drivers/web_search/test_duck_duck_go_web_search_driver.py b/tests/unit/drivers/web_search/test_duck_duck_go_web_search_driver.py index f3e835af1a..3d0a782eb4 100644 --- a/tests/unit/drivers/web_search/test_duck_duck_go_web_search_driver.py +++ b/tests/unit/drivers/web_search/test_duck_duck_go_web_search_driver.py @@ -7,7 +7,7 @@ class TestDuckDuckGoWebSearchDriver: - @pytest.fixture + @pytest.fixture() def driver(self, mocker): mock_response = [ {"title": "foo", "href": "bar", "body": "baz"}, @@ -18,7 +18,7 @@ def driver(self, mocker): return DuckDuckGoWebSearchDriver() - @pytest.fixture + @pytest.fixture() def driver_with_error(self, mocker): mocker.patch("duckduckgo_search.DDGS.text", side_effect=Exception("test_error")) diff --git a/tests/unit/drivers/web_search/test_google_web_search_driver.py b/tests/unit/drivers/web_search/test_google_web_search_driver.py index 275d246ec1..3809532de4 100644 --- a/tests/unit/drivers/web_search/test_google_web_search_driver.py +++ b/tests/unit/drivers/web_search/test_google_web_search_driver.py @@ -1,14 +1,13 @@ import json import pytest -from pytest import fixture from pytest_mock import MockerFixture from griptape.drivers import GoogleWebSearchDriver class TestGoogleWebSearchDriver: - @fixture + @pytest.fixture() def driver(self, mocker: MockerFixture): mock_response = mocker.Mock() mocker.patch.object( @@ -20,7 +19,7 @@ def driver(self, mocker: MockerFixture): return GoogleWebSearchDriver(api_key="test", search_id="test") - @fixture + @pytest.fixture() def driver_with_error(self, mocker: MockerFixture): mock_response = mocker.Mock() mock_response.status_code = 500 diff --git a/tests/unit/engines/extraction/test_csv_extraction_engine.py b/tests/unit/engines/extraction/test_csv_extraction_engine.py index 01125d1b1a..f69d8a0ba7 100644 --- a/tests/unit/engines/extraction/test_csv_extraction_engine.py +++ b/tests/unit/engines/extraction/test_csv_extraction_engine.py @@ -5,7 +5,7 @@ class TestCsvExtractionEngine: - @pytest.fixture + @pytest.fixture() def engine(self): return CsvExtractionEngine(prompt_driver=MockPromptDriver()) diff --git a/tests/unit/engines/extraction/test_json_extraction_engine.py b/tests/unit/engines/extraction/test_json_extraction_engine.py index bdf84d708b..d95adbb43c 100644 --- a/tests/unit/engines/extraction/test_json_extraction_engine.py +++ b/tests/unit/engines/extraction/test_json_extraction_engine.py @@ -7,7 +7,7 @@ class TestJsonExtractionEngine: - @pytest.fixture + @pytest.fixture() def engine(self): return JsonExtractionEngine( prompt_driver=MockPromptDriver( diff --git a/tests/unit/engines/rag/modules/generation/test_footnote_prompt_response_rag_module.py b/tests/unit/engines/rag/modules/generation/test_footnote_prompt_response_rag_module.py index ab4c0ba6a8..385cf0c04b 100644 --- a/tests/unit/engines/rag/modules/generation/test_footnote_prompt_response_rag_module.py +++ b/tests/unit/engines/rag/modules/generation/test_footnote_prompt_response_rag_module.py @@ -8,7 +8,7 @@ class TestFootnotePromptResponseRagModule: - @pytest.fixture + @pytest.fixture() def module(self): return FootnotePromptResponseRagModule(prompt_driver=MockPromptDriver()) diff --git a/tests/unit/engines/rag/modules/generation/test_prompt_response_rag_module.py b/tests/unit/engines/rag/modules/generation/test_prompt_response_rag_module.py index 31d095e614..2f8a912e22 100644 --- a/tests/unit/engines/rag/modules/generation/test_prompt_response_rag_module.py +++ b/tests/unit/engines/rag/modules/generation/test_prompt_response_rag_module.py @@ -7,7 +7,7 @@ class TestPromptResponseRagModule: - @pytest.fixture + @pytest.fixture() def module(self): return PromptResponseRagModule(prompt_driver=MockPromptDriver()) diff --git a/tests/unit/engines/rag/modules/generation/test_text_chunks_response_rag_module.py b/tests/unit/engines/rag/modules/generation/test_text_chunks_response_rag_module.py index 6ad4853a2c..ae4410b2c2 100644 --- a/tests/unit/engines/rag/modules/generation/test_text_chunks_response_rag_module.py +++ b/tests/unit/engines/rag/modules/generation/test_text_chunks_response_rag_module.py @@ -6,7 +6,7 @@ class TestTextChunksResponseRagModule: - @pytest.fixture + @pytest.fixture() def module(self): return TextChunksResponseRagModule() diff --git a/tests/unit/engines/rag/modules/retrieval/test_text_chunks_rerank_rag_module.py b/tests/unit/engines/rag/modules/retrieval/test_text_chunks_rerank_rag_module.py index cfa493d5a9..dda6e89e7f 100644 --- a/tests/unit/engines/rag/modules/retrieval/test_text_chunks_rerank_rag_module.py +++ b/tests/unit/engines/rag/modules/retrieval/test_text_chunks_rerank_rag_module.py @@ -8,7 +8,7 @@ class TestTextChunksRerankRagModule: - @pytest.fixture + @pytest.fixture() def mock_client(self, mocker): mock_client = mocker.patch("cohere.Client").return_value mock_client.rerank.return_value.results = [ diff --git a/tests/unit/engines/rag/modules/retrieval/test_text_loader_retrieval_rag_module.py b/tests/unit/engines/rag/modules/retrieval/test_text_loader_retrieval_rag_module.py index 7c69f674ac..69e334c7fa 100644 --- a/tests/unit/engines/rag/modules/retrieval/test_text_loader_retrieval_rag_module.py +++ b/tests/unit/engines/rag/modules/retrieval/test_text_loader_retrieval_rag_module.py @@ -11,7 +11,7 @@ class TestTextLoaderRetrievalRagModule: @pytest.fixture(autouse=True) - def mock_trafilatura_fetch_url(self, mocker): + def _mock_trafilatura_fetch_url(self, mocker): mocker.patch("trafilatura.fetch_url", return_value="foobar") def test_run(self): diff --git a/tests/unit/engines/rag/test_rag_engine.py b/tests/unit/engines/rag/test_rag_engine.py index 34be3ebed5..c3d728bb3a 100644 --- a/tests/unit/engines/rag/test_rag_engine.py +++ b/tests/unit/engines/rag/test_rag_engine.py @@ -9,7 +9,7 @@ class TestRagEngine: - @pytest.fixture + @pytest.fixture() def engine(self): return RagEngine( retrieval_stage=RetrievalRagStage( diff --git a/tests/unit/engines/summary/test_prompt_summary_engine.py b/tests/unit/engines/summary/test_prompt_summary_engine.py index f58319fdcc..e826a2b4d0 100644 --- a/tests/unit/engines/summary/test_prompt_summary_engine.py +++ b/tests/unit/engines/summary/test_prompt_summary_engine.py @@ -9,7 +9,7 @@ class TestPromptSummaryEngine: - @pytest.fixture + @pytest.fixture() def engine(self): return PromptSummaryEngine(prompt_driver=MockPromptDriver()) diff --git a/tests/unit/events/test_completion_chunk_event.py b/tests/unit/events/test_completion_chunk_event.py index 71b94919ce..943ea483fa 100644 --- a/tests/unit/events/test_completion_chunk_event.py +++ b/tests/unit/events/test_completion_chunk_event.py @@ -4,7 +4,7 @@ class TestCompletionChunkEvent: - @pytest.fixture + @pytest.fixture() def completion_chunk_event(self): return CompletionChunkEvent(token="foo bar") diff --git a/tests/unit/events/test_event_listener.py b/tests/unit/events/test_event_listener.py index b71d88ca6d..a79d2b6eac 100644 --- a/tests/unit/events/test_event_listener.py +++ b/tests/unit/events/test_event_listener.py @@ -23,7 +23,7 @@ class TestEventListener: - @pytest.fixture + @pytest.fixture() def pipeline(self): task = ToolkitTask("test", tools=[MockTool(name="Tool1")]) diff --git a/tests/unit/events/test_finish_actions_subtask_event.py b/tests/unit/events/test_finish_actions_subtask_event.py index e38ac2d5d5..5e2a0807a0 100644 --- a/tests/unit/events/test_finish_actions_subtask_event.py +++ b/tests/unit/events/test_finish_actions_subtask_event.py @@ -8,7 +8,7 @@ class TestFinishActionsSubtaskEvent: - @pytest.fixture + @pytest.fixture() def finish_subtask_event(self): valid_input = ( "Thought: need to test\n" diff --git a/tests/unit/events/test_finish_prompt_event.py b/tests/unit/events/test_finish_prompt_event.py index 2161c0df7d..397efe8a06 100644 --- a/tests/unit/events/test_finish_prompt_event.py +++ b/tests/unit/events/test_finish_prompt_event.py @@ -4,7 +4,7 @@ class TestFinishPromptEvent: - @pytest.fixture + @pytest.fixture() def finish_prompt_event(self): return FinishPromptEvent(input_token_count=321, output_token_count=123, result="foo bar", model="foo bar") diff --git a/tests/unit/events/test_finish_structure_run_event.py b/tests/unit/events/test_finish_structure_run_event.py index 0e9e61f4f3..9c09613141 100644 --- a/tests/unit/events/test_finish_structure_run_event.py +++ b/tests/unit/events/test_finish_structure_run_event.py @@ -5,7 +5,7 @@ class TestFinishStructureRunEvent: - @pytest.fixture + @pytest.fixture() def finish_structure_run_event(self): return FinishStructureRunEvent( structure_id="fizz", diff --git a/tests/unit/events/test_finish_task_event.py b/tests/unit/events/test_finish_task_event.py index d1f4e25c90..df1d6d42a0 100644 --- a/tests/unit/events/test_finish_task_event.py +++ b/tests/unit/events/test_finish_task_event.py @@ -7,7 +7,7 @@ class TestFinishTaskEvent: - @pytest.fixture + @pytest.fixture() def finish_task_event(self): task = PromptTask() agent = Agent(prompt_driver=MockPromptDriver()) diff --git a/tests/unit/events/test_start_actions_subtask_event.py b/tests/unit/events/test_start_actions_subtask_event.py index c468ae1161..8b628057cf 100644 --- a/tests/unit/events/test_start_actions_subtask_event.py +++ b/tests/unit/events/test_start_actions_subtask_event.py @@ -8,7 +8,7 @@ class TestStartActionsSubtaskEvent: - @pytest.fixture + @pytest.fixture() def start_subtask_event(self): valid_input = ( "Thought: need to test\n" diff --git a/tests/unit/events/test_start_prompt_event.py b/tests/unit/events/test_start_prompt_event.py index 038d6646bb..2d7e9368f1 100644 --- a/tests/unit/events/test_start_prompt_event.py +++ b/tests/unit/events/test_start_prompt_event.py @@ -5,7 +5,7 @@ class TestStartPromptEvent: - @pytest.fixture + @pytest.fixture() def start_prompt_event(self): prompt_stack = PromptStack() prompt_stack.add_user_message("foo") diff --git a/tests/unit/events/test_start_structure_run_event.py b/tests/unit/events/test_start_structure_run_event.py index 3b67b0069e..221f1a544c 100644 --- a/tests/unit/events/test_start_structure_run_event.py +++ b/tests/unit/events/test_start_structure_run_event.py @@ -5,7 +5,7 @@ class TestStartStructureRunEvent: - @pytest.fixture + @pytest.fixture() def start_structure_run_event(self): return StartStructureRunEvent( structure_id="fizz", input_task_input=TextArtifact("foo"), input_task_output=TextArtifact("bar") diff --git a/tests/unit/events/test_start_task_event.py b/tests/unit/events/test_start_task_event.py index be1d3d8f09..ea027f1472 100644 --- a/tests/unit/events/test_start_task_event.py +++ b/tests/unit/events/test_start_task_event.py @@ -7,7 +7,7 @@ class TestStartTaskEvent: - @pytest.fixture + @pytest.fixture() def start_task_event(self): task = PromptTask() agent = Agent(prompt_driver=MockPromptDriver()) diff --git a/tests/unit/loaders/conftest.py b/tests/unit/loaders/conftest.py index e1823a1544..494916be6a 100644 --- a/tests/unit/loaders/conftest.py +++ b/tests/unit/loaders/conftest.py @@ -4,7 +4,7 @@ import pytest -@pytest.fixture +@pytest.fixture() def path_from_resource_path(): def create_source(resource_path: str) -> Path: return Path(os.path.join(os.path.abspath(os.path.dirname(__file__)), "../../resources", resource_path)) @@ -12,7 +12,7 @@ def create_source(resource_path: str) -> Path: return create_source -@pytest.fixture +@pytest.fixture() def bytes_from_resource_path(path_from_resource_path): def create_source(resource_path: str) -> bytes: with open(path_from_resource_path(resource_path), "rb") as f: @@ -21,7 +21,7 @@ def create_source(resource_path: str) -> bytes: return create_source -@pytest.fixture +@pytest.fixture() def str_from_resource_path(path_from_resource_path): def test_csv_str(resource_path: str) -> str: with open(path_from_resource_path(resource_path)) as f: diff --git a/tests/unit/loaders/test_audio_loader.py b/tests/unit/loaders/test_audio_loader.py index 605e8d1b37..602284a280 100644 --- a/tests/unit/loaders/test_audio_loader.py +++ b/tests/unit/loaders/test_audio_loader.py @@ -5,15 +5,15 @@ class TestAudioLoader: - @pytest.fixture + @pytest.fixture() def loader(self): return AudioLoader() - @pytest.fixture + @pytest.fixture() def create_source(self, bytes_from_resource_path): return bytes_from_resource_path - @pytest.mark.parametrize("resource_path,suffix,mime_type", [("sentences.wav", ".wav", "audio/wav")]) + @pytest.mark.parametrize(("resource_path", "suffix", "mime_type"), [("sentences.wav", ".wav", "audio/wav")]) def test_load(self, resource_path, suffix, mime_type, loader, create_source): source = create_source(resource_path) diff --git a/tests/unit/loaders/test_csv_loader.py b/tests/unit/loaders/test_csv_loader.py index 89721077e3..a747afff71 100644 --- a/tests/unit/loaders/test_csv_loader.py +++ b/tests/unit/loaders/test_csv_loader.py @@ -13,7 +13,7 @@ def loader(self, request): else: return CsvLoader(embedding_driver=MockEmbeddingDriver(), encoding=encoding) - @pytest.fixture + @pytest.fixture() def loader_with_pipe_delimiter(self): return CsvLoader(embedding_driver=MockEmbeddingDriver(), delimiter="|") diff --git a/tests/unit/loaders/test_dataframe_loader.py b/tests/unit/loaders/test_dataframe_loader.py index 51d878ec9b..5c2a57ed6a 100644 --- a/tests/unit/loaders/test_dataframe_loader.py +++ b/tests/unit/loaders/test_dataframe_loader.py @@ -8,7 +8,7 @@ class TestDataFrameLoader: - @pytest.fixture + @pytest.fixture() def loader(self): return DataFrameLoader(embedding_driver=MockEmbeddingDriver()) diff --git a/tests/unit/loaders/test_email_loader.py b/tests/unit/loaders/test_email_loader.py index ce99075bf6..f1e057453e 100644 --- a/tests/unit/loaders/test_email_loader.py +++ b/tests/unit/loaders/test_email_loader.py @@ -17,7 +17,7 @@ def mock_imap_connection(self, mocker): mock_imap_connection.__enter__.return_value = mock_imap_connection return mock_imap_connection - @pytest.fixture + @pytest.fixture() def mock_login(self, mock_imap_connection): return mock_imap_connection.login @@ -27,7 +27,7 @@ def mock_select(self, mock_imap_connection): mock_select.return_value = to_select_response("OK", 1) return mock_select - @pytest.fixture + @pytest.fixture() def mock_search(self, mock_imap_connection): return mock_imap_connection.search @@ -37,7 +37,7 @@ def mock_fetch(self, mock_imap_connection): mock_fetch.return_value = to_fetch_message("message", "text/plain") return mock_fetch - @pytest.fixture + @pytest.fixture() def loader(self): return EmailLoader(imap_url="an.email.server.hostname", username="username", password="password") diff --git a/tests/unit/loaders/test_image_loader.py b/tests/unit/loaders/test_image_loader.py index 2a90d6b5d6..eca4cbccc5 100644 --- a/tests/unit/loaders/test_image_loader.py +++ b/tests/unit/loaders/test_image_loader.py @@ -5,20 +5,20 @@ class TestImageLoader: - @pytest.fixture + @pytest.fixture() def loader(self): return ImageLoader() - @pytest.fixture + @pytest.fixture() def png_loader(self): return ImageLoader(format="png") - @pytest.fixture + @pytest.fixture() def create_source(self, bytes_from_resource_path): return bytes_from_resource_path @pytest.mark.parametrize( - "resource_path,suffix,mime_type", + ("resource_path", "suffix", "mime_type"), [ ("small.png", ".png", "image/png"), ("small.jpg", ".jpeg", "image/jpeg"), diff --git a/tests/unit/loaders/test_pdf_loader.py b/tests/unit/loaders/test_pdf_loader.py index 337a010b2d..3f4f7848e5 100644 --- a/tests/unit/loaders/test_pdf_loader.py +++ b/tests/unit/loaders/test_pdf_loader.py @@ -7,11 +7,11 @@ class TestPdfLoader: - @pytest.fixture + @pytest.fixture() def loader(self): return PdfLoader(max_tokens=MAX_TOKENS, embedding_driver=MockEmbeddingDriver()) - @pytest.fixture + @pytest.fixture() def create_source(self, bytes_from_resource_path): return bytes_from_resource_path diff --git a/tests/unit/loaders/test_sql_loader.py b/tests/unit/loaders/test_sql_loader.py index dcbf84a534..fbfa6d4fa9 100644 --- a/tests/unit/loaders/test_sql_loader.py +++ b/tests/unit/loaders/test_sql_loader.py @@ -9,7 +9,7 @@ class TestSqlLoader: - @pytest.fixture + @pytest.fixture() def loader(self): sql_loader = SqlLoader( sql_driver=SqlDriver( diff --git a/tests/unit/loaders/test_web_loader.py b/tests/unit/loaders/test_web_loader.py index 57c68bc275..f264ce667a 100644 --- a/tests/unit/loaders/test_web_loader.py +++ b/tests/unit/loaders/test_web_loader.py @@ -9,10 +9,10 @@ class TestWebLoader: @pytest.fixture(autouse=True) - def mock_trafilatura_fetch_url(self, mocker): + def _mock_trafilatura_fetch_url(self, mocker): mocker.patch("trafilatura.fetch_url", return_value="foobar") - @pytest.fixture + @pytest.fixture() def loader(self): return WebLoader(max_tokens=MAX_TOKENS, embedding_driver=MockEmbeddingDriver()) diff --git a/tests/unit/memory/meta/test_action_subtask_meta_entry.py b/tests/unit/memory/meta/test_action_subtask_meta_entry.py index c406677133..0a51e72274 100644 --- a/tests/unit/memory/meta/test_action_subtask_meta_entry.py +++ b/tests/unit/memory/meta/test_action_subtask_meta_entry.py @@ -4,7 +4,7 @@ class TestActionSubtaskMetaEntry: - @pytest.fixture + @pytest.fixture() def entry(self): return ActionSubtaskMetaEntry(thought="foo", actions="[]", answer="baz") diff --git a/tests/unit/memory/meta/test_meta_memory.py b/tests/unit/memory/meta/test_meta_memory.py index 73f552d0d6..5a12495299 100644 --- a/tests/unit/memory/meta/test_meta_memory.py +++ b/tests/unit/memory/meta/test_meta_memory.py @@ -4,7 +4,7 @@ class TestMetaMemory: - @pytest.fixture + @pytest.fixture() def memory(self): return MetaMemory() diff --git a/tests/unit/memory/tool/storage/test_blob_artifact_storage.py b/tests/unit/memory/tool/storage/test_blob_artifact_storage.py index 0b28870e10..c7f2cfcbdf 100644 --- a/tests/unit/memory/tool/storage/test_blob_artifact_storage.py +++ b/tests/unit/memory/tool/storage/test_blob_artifact_storage.py @@ -5,7 +5,7 @@ class TestBlobArtifactStorage: - @pytest.fixture + @pytest.fixture() def storage(self): return BlobArtifactStorage() diff --git a/tests/unit/memory/tool/storage/test_text_artifact_storage.py b/tests/unit/memory/tool/storage/test_text_artifact_storage.py index a3814145c1..64f44c5811 100644 --- a/tests/unit/memory/tool/storage/test_text_artifact_storage.py +++ b/tests/unit/memory/tool/storage/test_text_artifact_storage.py @@ -5,7 +5,7 @@ class TestTextArtifactStorage: - @pytest.fixture + @pytest.fixture() def storage(self): return defaults.text_tool_artifact_storage() diff --git a/tests/unit/memory/tool/test_task_memory.py b/tests/unit/memory/tool/test_task_memory.py index 279c3ca3f7..53e4703a6d 100644 --- a/tests/unit/memory/tool/test_task_memory.py +++ b/tests/unit/memory/tool/test_task_memory.py @@ -11,10 +11,10 @@ class TestTaskMemory: @pytest.fixture(autouse=True) - def mock_griptape(self, mocker): + def _mock_griptape(self, mocker): mocker.patch("griptape.engines.CsvExtractionEngine.extract", return_value=[CsvRowArtifact({"foo": "bar"})]) - @pytest.fixture + @pytest.fixture() def memory(self): return defaults.text_task_memory("MyMemory") diff --git a/tests/unit/mixins/test_activity_mixin.py b/tests/unit/mixins/test_activity_mixin.py index 5dff5aa0d8..91e0c3a67b 100644 --- a/tests/unit/mixins/test_activity_mixin.py +++ b/tests/unit/mixins/test_activity_mixin.py @@ -5,7 +5,7 @@ class TestActivityMixin: - @pytest.fixture + @pytest.fixture() def tool(self): return MockTool(test_field="hello", test_int=5) diff --git a/tests/unit/structures/test_agent.py b/tests/unit/structures/test_agent.py index 414861e29e..a09ad0f9a7 100644 --- a/tests/unit/structures/test_agent.py +++ b/tests/unit/structures/test_agent.py @@ -49,8 +49,8 @@ def test_rules_and_rulesets(self): with pytest.raises(ValueError): Agent(rules=[Rule("foo test")], rulesets=[Ruleset("Bar", [Rule("bar test")])]) + agent = Agent() with pytest.raises(ValueError): - agent = Agent() agent.add_task(PromptTask(rules=[Rule("foo test")], rulesets=[Ruleset("Bar", [Rule("bar test")])])) def test_with_task_memory(self): diff --git a/tests/unit/structures/test_pipeline.py b/tests/unit/structures/test_pipeline.py index a9028cf083..38f8abfb32 100644 --- a/tests/unit/structures/test_pipeline.py +++ b/tests/unit/structures/test_pipeline.py @@ -15,7 +15,7 @@ class TestPipeline: - @pytest.fixture + @pytest.fixture() def waiting_task(self): def fn(task): time.sleep(2) @@ -23,7 +23,7 @@ def fn(task): return CodeExecutionTask(run_fn=fn) - @pytest.fixture + @pytest.fixture() def error_artifact_task(self): def fn(task): return ErrorArtifact("error") @@ -77,8 +77,8 @@ def test_rules_and_rulesets(self): with pytest.raises(ValueError): Pipeline(rules=[Rule("foo test")], rulesets=[Ruleset("Bar", [Rule("bar test")])]) + pipeline = Pipeline() with pytest.raises(ValueError): - pipeline = Pipeline() pipeline.add_task(PromptTask(rules=[Rule("foo test")], rulesets=[Ruleset("Bar", [Rule("bar test")])])) def test_with_no_task_memory(self): diff --git a/tests/unit/structures/test_workflow.py b/tests/unit/structures/test_workflow.py index 44b27f1bad..2be164ea72 100644 --- a/tests/unit/structures/test_workflow.py +++ b/tests/unit/structures/test_workflow.py @@ -1,7 +1,6 @@ import time import pytest -from pytest import fixture from griptape.artifacts import ErrorArtifact, TextArtifact from griptape.memory.structure import ConversationMemory @@ -15,7 +14,7 @@ class TestWorkflow: - @fixture + @pytest.fixture() def waiting_task(self): def fn(task): time.sleep(2) @@ -23,7 +22,7 @@ def fn(task): return CodeExecutionTask(run_fn=fn) - @fixture + @pytest.fixture() def error_artifact_task(self): def fn(task): return ErrorArtifact("error") @@ -76,8 +75,8 @@ def test_rules_and_rulesets(self): with pytest.raises(ValueError): Workflow(rules=[Rule("foo test")], rulesets=[Ruleset("Bar", [Rule("bar test")])]) + workflow = Workflow() with pytest.raises(ValueError): - workflow = Workflow() workflow.add_task(PromptTask(rules=[Rule("foo test")], rulesets=[Ruleset("Bar", [Rule("bar test")])])) def test_with_no_task_memory(self): diff --git a/tests/unit/tasks/test_audio_transcription_task.py b/tests/unit/tasks/test_audio_transcription_task.py index 66d26f08eb..f4bc0e8b83 100644 --- a/tests/unit/tasks/test_audio_transcription_task.py +++ b/tests/unit/tasks/test_audio_transcription_task.py @@ -11,11 +11,11 @@ class TestAudioTranscriptionTask: - @pytest.fixture + @pytest.fixture() def audio_artifact(self): return AudioArtifact(value=b"audio data", format="mp3") - @pytest.fixture + @pytest.fixture() def audio_transcription_engine(self): return Mock() diff --git a/tests/unit/tasks/test_base_audio_input_task.py b/tests/unit/tasks/test_base_audio_input_task.py index 6ace6f45b3..e16c6536c4 100644 --- a/tests/unit/tasks/test_base_audio_input_task.py +++ b/tests/unit/tasks/test_base_audio_input_task.py @@ -6,7 +6,7 @@ class TestBaseAudioInputTask: - @pytest.fixture + @pytest.fixture() def audio_artifact(self): return AudioArtifact(b"audio content", format="mp3") diff --git a/tests/unit/tasks/test_base_task.py b/tests/unit/tasks/test_base_task.py index bb60bae61f..7a1afcf07a 100644 --- a/tests/unit/tasks/test_base_task.py +++ b/tests/unit/tasks/test_base_task.py @@ -10,7 +10,7 @@ class TestBaseTask: - @pytest.fixture + @pytest.fixture() def task(self): agent = Agent(prompt_driver=MockPromptDriver(), embedding_driver=MockEmbeddingDriver(), tools=[MockTool()]) diff --git a/tests/unit/tasks/test_csv_extraction_task.py b/tests/unit/tasks/test_csv_extraction_task.py index 14c426fe76..7d37c3897b 100644 --- a/tests/unit/tasks/test_csv_extraction_task.py +++ b/tests/unit/tasks/test_csv_extraction_task.py @@ -8,7 +8,7 @@ class TestCsvExtractionTask: - @pytest.fixture + @pytest.fixture() def task(self): return CsvExtractionTask(args={"column_names": ["test1"]}) diff --git a/tests/unit/tasks/test_extraction_task.py b/tests/unit/tasks/test_extraction_task.py index ac6a5c34e4..afa73a506f 100644 --- a/tests/unit/tasks/test_extraction_task.py +++ b/tests/unit/tasks/test_extraction_task.py @@ -7,7 +7,7 @@ class TestExtractionTask: - @pytest.fixture + @pytest.fixture() def task(self): return ExtractionTask( extraction_engine=CsvExtractionEngine(prompt_driver=MockPromptDriver()), args={"column_names": ["test1"]} diff --git a/tests/unit/tasks/test_image_query_task.py b/tests/unit/tasks/test_image_query_task.py index 95406a95d4..549009fc11 100644 --- a/tests/unit/tasks/test_image_query_task.py +++ b/tests/unit/tasks/test_image_query_task.py @@ -12,18 +12,18 @@ class TestImageQueryTask: - @pytest.fixture + @pytest.fixture() def image_query_engine(self) -> Mock: mock = Mock() mock.run.return_value = TextArtifact("image") return mock - @pytest.fixture + @pytest.fixture() def text_artifact(self): return TextArtifact(value="some text") - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact(value=b"some image data", format="png", width=512, height=512) diff --git a/tests/unit/tasks/test_inpainting_image_generation_task.py b/tests/unit/tasks/test_inpainting_image_generation_task.py index afade8d394..ff287d79a7 100644 --- a/tests/unit/tasks/test_inpainting_image_generation_task.py +++ b/tests/unit/tasks/test_inpainting_image_generation_task.py @@ -12,11 +12,11 @@ class TestInpaintingImageGenerationTask: - @pytest.fixture + @pytest.fixture() def text_artifact(self): return TextArtifact(value="some text") - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact(value=b"some image data", format="png", width=512, height=512) diff --git a/tests/unit/tasks/test_json_extraction_task.py b/tests/unit/tasks/test_json_extraction_task.py index f42448663a..ba7d1ce305 100644 --- a/tests/unit/tasks/test_json_extraction_task.py +++ b/tests/unit/tasks/test_json_extraction_task.py @@ -9,7 +9,7 @@ class TestJsonExtractionTask: - @pytest.fixture + @pytest.fixture() def task(self): return JsonExtractionTask("foo", args={"template_schema": Schema({"foo": "bar"}).json_schema("TemplateSchema")}) diff --git a/tests/unit/tasks/test_outpainting_image_generation_task.py b/tests/unit/tasks/test_outpainting_image_generation_task.py index 1e59711645..7de530330d 100644 --- a/tests/unit/tasks/test_outpainting_image_generation_task.py +++ b/tests/unit/tasks/test_outpainting_image_generation_task.py @@ -12,11 +12,11 @@ class TestOutpaintingImageGenerationTask: - @pytest.fixture + @pytest.fixture() def text_artifact(self): return TextArtifact(value="some text") - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact(value=b"some image data", format="png", width=512, height=512) diff --git a/tests/unit/tasks/test_rag_task.py b/tests/unit/tasks/test_rag_task.py index c9a6a844d4..b205d385ae 100644 --- a/tests/unit/tasks/test_rag_task.py +++ b/tests/unit/tasks/test_rag_task.py @@ -9,7 +9,7 @@ class TestRagTask: - @pytest.fixture + @pytest.fixture() def task(self): return RagTask( input="test", diff --git a/tests/unit/tasks/test_tool_task.py b/tests/unit/tasks/test_tool_task.py index c30a08218e..dfc679919c 100644 --- a/tests/unit/tasks/test_tool_task.py +++ b/tests/unit/tasks/test_tool_task.py @@ -165,7 +165,7 @@ class TestToolTask: "$schema": "http://json-schema.org/draft-07/schema#", } - @pytest.fixture + @pytest.fixture() def agent(self): output_dict = {"tag": "foo", "name": "MockTool", "path": "test", "input": {"values": {"test": "foobar"}}} diff --git a/tests/unit/tasks/test_variation_image_generation_task.py b/tests/unit/tasks/test_variation_image_generation_task.py index 1189e7fc62..3f865931f9 100644 --- a/tests/unit/tasks/test_variation_image_generation_task.py +++ b/tests/unit/tasks/test_variation_image_generation_task.py @@ -12,11 +12,11 @@ class TestVariationImageGenerationTask: - @pytest.fixture + @pytest.fixture() def text_artifact(self): return TextArtifact(value="some text") - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact(value=b"some image data", format="png", width=512, height=512) diff --git a/tests/unit/tokenizers/test_amazon_bedrock_tokenizer.py b/tests/unit/tokenizers/test_amazon_bedrock_tokenizer.py index a5a4fbba54..bb928c1c32 100644 --- a/tests/unit/tokenizers/test_amazon_bedrock_tokenizer.py +++ b/tests/unit/tokenizers/test_amazon_bedrock_tokenizer.py @@ -4,12 +4,12 @@ class TestAmazonBedrockTokenizer: - @pytest.fixture + @pytest.fixture() def tokenizer(self, request): return AmazonBedrockTokenizer(model=request.param) @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("anthropic.claude-v2:1", 4), ("anthropic.claude-v2", 4), @@ -22,7 +22,7 @@ def test_token_count(self, tokenizer, expected): assert tokenizer.count_tokens("foo bar huzzah") == expected @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("anthropic.claude-v2", 99996), ("anthropic.claude-v2:1", 199996), @@ -35,7 +35,7 @@ def test_input_tokens_left(self, tokenizer, expected): assert tokenizer.count_input_tokens_left("foo bar huzzah") == expected @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("anthropic.claude-v2", 4092), ("anthropic.claude-v2:1", 4092), diff --git a/tests/unit/tokenizers/test_anthropic_tokenizer.py b/tests/unit/tokenizers/test_anthropic_tokenizer.py index 70c6fec966..859ba9684d 100644 --- a/tests/unit/tokenizers/test_anthropic_tokenizer.py +++ b/tests/unit/tokenizers/test_anthropic_tokenizer.py @@ -4,12 +4,12 @@ class TestAnthropicTokenizer: - @pytest.fixture + @pytest.fixture() def tokenizer(self, request): return AnthropicTokenizer(model=request.param) @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [("claude-2.1", 5), ("claude-2.0", 5), ("claude-3-opus", 5), ("claude-3-sonnet", 5), ("claude-3-haiku", 5)], indirect=["tokenizer"], ) @@ -17,7 +17,7 @@ def test_token_count(self, tokenizer, expected): assert tokenizer.count_tokens("foo bar huzzah") == expected @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("claude-2.0", 99995), ("claude-2.1", 199995), @@ -31,7 +31,7 @@ def test_input_tokens_left(self, tokenizer, expected): assert tokenizer.count_input_tokens_left("foo bar huzzah") == expected @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("claude-2.0", 4091), ("claude-2.1", 4091), diff --git a/tests/unit/tokenizers/test_cohere_tokenizer.py b/tests/unit/tokenizers/test_cohere_tokenizer.py index 049f94d247..3999ec399a 100644 --- a/tests/unit/tokenizers/test_cohere_tokenizer.py +++ b/tests/unit/tokenizers/test_cohere_tokenizer.py @@ -11,7 +11,7 @@ def mock_client(self, mocker): return mock_client - @pytest.fixture + @pytest.fixture() def tokenizer(self): return CohereTokenizer(model="command", client=cohere.Client("foobar")) diff --git a/tests/unit/tokenizers/test_dummy_tokenizer.py b/tests/unit/tokenizers/test_dummy_tokenizer.py index 90269eb2a7..5d770d1aaf 100644 --- a/tests/unit/tokenizers/test_dummy_tokenizer.py +++ b/tests/unit/tokenizers/test_dummy_tokenizer.py @@ -5,7 +5,7 @@ class TestDummyTokenizer: - @pytest.fixture + @pytest.fixture() def tokenizer(self): return DummyTokenizer() diff --git a/tests/unit/tokenizers/test_google_tokenizer.py b/tests/unit/tokenizers/test_google_tokenizer.py index 60c14f889f..41012f5d62 100644 --- a/tests/unit/tokenizers/test_google_tokenizer.py +++ b/tests/unit/tokenizers/test_google_tokenizer.py @@ -15,22 +15,22 @@ def mock_generative_model(self, mocker): return mock_generative_model - @pytest.fixture + @pytest.fixture() def tokenizer(self, request): return GoogleTokenizer(model=request.param, api_key="1234") - @pytest.mark.parametrize("tokenizer,expected", [("gemini-pro", 5)], indirect=["tokenizer"]) + @pytest.mark.parametrize(("tokenizer", "expected"), [("gemini-pro", 5)], indirect=["tokenizer"]) def test_token_count(self, tokenizer, expected): assert tokenizer.count_tokens("foo bar huzzah") == expected assert tokenizer.count_tokens(PromptStack(messages=[Message(content="foo", role="user")])) == expected assert tokenizer.count_tokens(["foo", "bar", "huzzah"]) == expected - @pytest.mark.parametrize("tokenizer,expected", [("gemini-pro", 30715)], indirect=["tokenizer"]) + @pytest.mark.parametrize(("tokenizer", "expected"), [("gemini-pro", 30715)], indirect=["tokenizer"]) def test_input_tokens_left(self, tokenizer, expected): assert tokenizer.count_input_tokens_left("foo bar huzzah") == expected assert tokenizer.count_input_tokens_left(["foo", "bar", "huzzah"]) == expected - @pytest.mark.parametrize("tokenizer,expected", [("gemini-pro", 2043)], indirect=["tokenizer"]) + @pytest.mark.parametrize(("tokenizer", "expected"), [("gemini-pro", 2043)], indirect=["tokenizer"]) def test_output_tokens_left(self, tokenizer, expected): assert tokenizer.count_output_tokens_left("foo bar huzzah") == expected assert tokenizer.count_output_tokens_left(["foo", "bar", "huzzah"]) == expected diff --git a/tests/unit/tokenizers/test_hugging_face_tokenizer.py b/tests/unit/tokenizers/test_hugging_face_tokenizer.py index 2c98a33f47..e717140e39 100644 --- a/tests/unit/tokenizers/test_hugging_face_tokenizer.py +++ b/tests/unit/tokenizers/test_hugging_face_tokenizer.py @@ -8,7 +8,7 @@ class TestHuggingFaceTokenizer: - @pytest.fixture + @pytest.fixture() def tokenizer(self): return HuggingFaceTokenizer(model="gpt2", max_output_tokens=1024) diff --git a/tests/unit/tokenizers/test_openai_tokenizer.py b/tests/unit/tokenizers/test_openai_tokenizer.py index 026143ab72..697184546b 100644 --- a/tests/unit/tokenizers/test_openai_tokenizer.py +++ b/tests/unit/tokenizers/test_openai_tokenizer.py @@ -4,12 +4,12 @@ class TestOpenAiTokenizer: - @pytest.fixture + @pytest.fixture() def tokenizer(self, request): return OpenAiTokenizer(model=request.param) @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("gpt-4-1106", 5), ("gpt-4-32k", 5), @@ -35,7 +35,7 @@ def test_initialize_with_unknown_model(self): assert tokenizer.max_input_tokens == OpenAiTokenizer.DEFAULT_MAX_TOKENS - OpenAiTokenizer.TOKEN_OFFSET @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("gpt-4-1106", 19), ("gpt-4-32k", 19), @@ -46,7 +46,6 @@ def test_initialize_with_unknown_model(self): ("gpt-3.5-turbo", 19), ("gpt-35-turbo-16k", 19), ("gpt-35-turbo", 19), - ("gpt-35-turbo", 19), ], indirect=["tokenizer"], ) @@ -58,7 +57,7 @@ def test_token_count_for_messages(self, tokenizer, expected): == expected ) - @pytest.mark.parametrize("tokenizer,expected", [("not-real-model", 19)], indirect=["tokenizer"]) + @pytest.mark.parametrize(("tokenizer", "expected"), [("not-real-model", 19)], indirect=["tokenizer"]) def test_token_count_for_messages_unknown_model(self, tokenizer, expected): with pytest.raises(NotImplementedError): tokenizer.count_tokens( @@ -66,7 +65,7 @@ def test_token_count_for_messages_unknown_model(self, tokenizer, expected): ) @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("gpt-4-1106", 127987), ("gpt-4o", 127987), @@ -87,7 +86,7 @@ def test_input_tokens_left(self, tokenizer, expected): assert tokenizer.count_input_tokens_left("foo bar huzzah") == expected @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [ ("gpt-4-1106", 4091), ("gpt-4-32k", 4091), diff --git a/tests/unit/tokenizers/test_simple_tokenizer.py b/tests/unit/tokenizers/test_simple_tokenizer.py index 7402f5e0e9..d2598067a2 100644 --- a/tests/unit/tokenizers/test_simple_tokenizer.py +++ b/tests/unit/tokenizers/test_simple_tokenizer.py @@ -4,7 +4,7 @@ class TestSimpleTokenizer: - @pytest.fixture + @pytest.fixture() def tokenizer(self): return SimpleTokenizer(max_input_tokens=1024, max_output_tokens=4096, characters_per_token=6) diff --git a/tests/unit/tokenizers/test_voyageai_tokenizer.py b/tests/unit/tokenizers/test_voyageai_tokenizer.py index d4529b3fa2..6f631ae4ee 100644 --- a/tests/unit/tokenizers/test_voyageai_tokenizer.py +++ b/tests/unit/tokenizers/test_voyageai_tokenizer.py @@ -11,12 +11,12 @@ def mock_client(self, mocker): return mock_client - @pytest.fixture + @pytest.fixture() def tokenizer(self, request): return VoyageAiTokenizer(model=request.param) @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [("voyage-large-2", 5), ("voyage-code-2", 5), ("voyage-2", 5), ("voyage-lite-02-instruct", 5)], indirect=["tokenizer"], ) @@ -24,7 +24,7 @@ def test_token_count(self, tokenizer, expected): assert tokenizer.count_tokens("foo bar huzzah") == expected @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [("voyage-large-2", 15995), ("voyage-code-2", 15995), ("voyage-2", 3995), ("voyage-lite-02-instruct", 3995)], indirect=["tokenizer"], ) @@ -32,7 +32,7 @@ def test_input_tokens_left(self, tokenizer, expected): assert tokenizer.count_input_tokens_left("foo bar huzzah") == expected @pytest.mark.parametrize( - "tokenizer,expected", + ("tokenizer", "expected"), [("voyage-large-2", 0), ("voyage-code-2", 0), ("voyage-2", 0), ("voyage-lite-02-instruct", 0)], indirect=["tokenizer"], ) diff --git a/tests/unit/tools/test_aws_iam.py b/tests/unit/tools/test_aws_iam.py index a399fcc544..54dbaa5fb9 100644 --- a/tests/unit/tools/test_aws_iam.py +++ b/tests/unit/tools/test_aws_iam.py @@ -1,13 +1,13 @@ import boto3 -from pytest import fixture +import pytest from griptape.tools import AwsIamClient from tests.utils.aws import mock_aws_credentials class TestAwsIamClient: - @fixture(autouse=True) - def run_before_and_after_tests(self): + @pytest.fixture(autouse=True) + def _run_before_and_after_tests(self): mock_aws_credentials() def test_get_user_policy(self): diff --git a/tests/unit/tools/test_aws_s3.py b/tests/unit/tools/test_aws_s3.py index d75d5c7347..5c6a4c1513 100644 --- a/tests/unit/tools/test_aws_s3.py +++ b/tests/unit/tools/test_aws_s3.py @@ -1,13 +1,13 @@ import boto3 -from pytest import fixture +import pytest from griptape.tools import AwsS3Client from tests.utils.aws import mock_aws_credentials class TestAwsS3Client: - @fixture(autouse=True) - def run_before_and_after_tests(self): + @pytest.fixture(autouse=True) + def _run_before_and_after_tests(self): mock_aws_credentials() def test_get_bucket_acl(self): diff --git a/tests/unit/tools/test_base_tool.py b/tests/unit/tools/test_base_tool.py index 2c114cbd28..a4d4097c10 100644 --- a/tests/unit/tools/test_base_tool.py +++ b/tests/unit/tools/test_base_tool.py @@ -155,7 +155,7 @@ class TestBaseTool: "$schema": "http://json-schema.org/draft-07/schema#", } - @pytest.fixture + @pytest.fixture() def tool(self): return MockTool(test_field="hello", test_int=5, test_dict={"foo": "bar"}) @@ -254,6 +254,6 @@ def test_to_native_tool_name(self, tool): assert tool.to_native_tool_name(tool.test) == "MockTool_test" + tool.name = "mock_tool" with pytest.raises(ValueError): - tool.name = "mock_tool" tool.to_native_tool_name(tool.foo) diff --git a/tests/unit/tools/test_computer.py b/tests/unit/tools/test_computer.py index 96827b32c8..95de18ae3c 100644 --- a/tests/unit/tools/test_computer.py +++ b/tests/unit/tools/test_computer.py @@ -5,7 +5,7 @@ class TestComputer: - @pytest.fixture + @pytest.fixture() def computer(self): return Computer(docker_client=make_fake_client(), install_dependencies_on_init=False) diff --git a/tests/unit/tools/test_email_client.py b/tests/unit/tools/test_email_client.py index 081b62ca4a..cf99009b8a 100644 --- a/tests/unit/tools/test_email_client.py +++ b/tests/unit/tools/test_email_client.py @@ -27,7 +27,7 @@ def mock_smtp_ssl(self, mocker): mock_smtp_ssl.__enter__.return_value = mock_smtp_ssl return mock_smtp_ssl - @pytest.fixture + @pytest.fixture() def client(self): return EmailClient( username="fake-username", @@ -37,12 +37,12 @@ def client(self): mailboxes={"INBOX": "default mailbox for incoming email", "SENT": "default mailbox for sent email"}, ) - @pytest.fixture + @pytest.fixture() def send_params(self): return {"values": {"to": "fake@fake.fake", "subject": "fake-subject", "body": "fake-body"}} @pytest.mark.parametrize( - "values,query", + ("values", "query"), [ ({"label": "fake-label"}, EmailLoader.EmailQuery(label="fake-label")), ({"label": "fake-label", "key": "fake-key"}, EmailLoader.EmailQuery(label="fake-label", key="fake-key")), diff --git a/tests/unit/tools/test_file_manager.py b/tests/unit/tools/test_file_manager.py index ac1b3e3fe9..57dd2c83ec 100644 --- a/tests/unit/tools/test_file_manager.py +++ b/tests/unit/tools/test_file_manager.py @@ -14,14 +14,14 @@ class TestFileManager: - @pytest.fixture + @pytest.fixture() def file_manager(self): return FileManager( input_memory=[defaults.text_task_memory("Memory1")], file_manager_driver=LocalFileManagerDriver(workdir=os.path.abspath(os.path.dirname(__file__))), ) - @pytest.fixture + @pytest.fixture() def temp_dir(self): with tempfile.TemporaryDirectory() as temp_dir: yield temp_dir diff --git a/tests/unit/tools/test_google_docs_client.py b/tests/unit/tools/test_google_docs_client.py index ad74fcaca9..a42fddda32 100644 --- a/tests/unit/tools/test_google_docs_client.py +++ b/tests/unit/tools/test_google_docs_client.py @@ -2,7 +2,7 @@ class TestGoogleDocsClient: - @pytest.fixture + @pytest.fixture() def mock_docs_client(self): from griptape.tools import GoogleDocsClient diff --git a/tests/unit/tools/test_griptape_cloud_knowledge_base_client.py b/tests/unit/tools/test_griptape_cloud_knowledge_base_client.py index 5bfd2ab1a5..7d75d8670c 100644 --- a/tests/unit/tools/test_griptape_cloud_knowledge_base_client.py +++ b/tests/unit/tools/test_griptape_cloud_knowledge_base_client.py @@ -5,7 +5,7 @@ class TestGriptapeCloudKnowledgeBaseClient: - @pytest.fixture + @pytest.fixture() def client(self, mocker): from griptape.tools import GriptapeCloudKnowledgeBaseClient @@ -23,7 +23,7 @@ def client(self, mocker): base_url="https://api.griptape.ai", api_key="foo bar", knowledge_base_id="1" ) - @pytest.fixture + @pytest.fixture() def client_no_description(self, mocker): from griptape.tools import GriptapeCloudKnowledgeBaseClient @@ -36,7 +36,7 @@ def client_no_description(self, mocker): base_url="https://api.griptape.ai", api_key="foo bar", knowledge_base_id="1" ) - @pytest.fixture + @pytest.fixture() def client_kb_not_found(self, mocker): from griptape.tools import GriptapeCloudKnowledgeBaseClient @@ -49,7 +49,7 @@ def client_kb_not_found(self, mocker): base_url="https://api.griptape.ai", api_key="foo bar", knowledge_base_id="1" ) - @pytest.fixture + @pytest.fixture() def client_kb_error(self, mocker): from griptape.tools import GriptapeCloudKnowledgeBaseClient diff --git a/tests/unit/tools/test_inpainting_image_generation_client.py b/tests/unit/tools/test_inpainting_image_generation_client.py index 1c48ce0fe4..14ddcb5b6e 100644 --- a/tests/unit/tools/test_inpainting_image_generation_client.py +++ b/tests/unit/tools/test_inpainting_image_generation_client.py @@ -10,18 +10,18 @@ class TestInpaintingImageGenerationClient: - @pytest.fixture + @pytest.fixture() def image_generation_engine(self) -> Mock: return Mock() - @pytest.fixture + @pytest.fixture() def image_loader(self) -> Mock: loader = Mock() loader.load.return_value = ImageArtifact(value=b"image_data", format="png", width=512, height=512) return loader - @pytest.fixture + @pytest.fixture() def image_generator(self, image_generation_engine, image_loader) -> InpaintingImageGenerationClient: return InpaintingImageGenerationClient(engine=image_generation_engine, image_loader=image_loader) diff --git a/tests/unit/tools/test_openweather_client.py b/tests/unit/tools/test_openweather_client.py index cead389584..89b80e1648 100644 --- a/tests/unit/tools/test_openweather_client.py +++ b/tests/unit/tools/test_openweather_client.py @@ -6,7 +6,7 @@ from griptape.tools import OpenWeatherClient -@pytest.fixture +@pytest.fixture() def client(): return OpenWeatherClient(api_key="YOUR_API_KEY") diff --git a/tests/unit/tools/test_outpainting_image_variation_client.py b/tests/unit/tools/test_outpainting_image_variation_client.py index 45a51c7be1..d604574cb1 100644 --- a/tests/unit/tools/test_outpainting_image_variation_client.py +++ b/tests/unit/tools/test_outpainting_image_variation_client.py @@ -10,18 +10,18 @@ class TestOutpaintingImageGenerationClient: - @pytest.fixture + @pytest.fixture() def image_generation_engine(self) -> Mock: return Mock() - @pytest.fixture + @pytest.fixture() def image_loader(self) -> Mock: loader = Mock() loader.load.return_value = ImageArtifact(value=b"image_data", format="png", width=512, height=512) return loader - @pytest.fixture + @pytest.fixture() def image_generator(self, image_generation_engine, image_loader) -> OutpaintingImageGenerationClient: return OutpaintingImageGenerationClient(engine=image_generation_engine, image_loader=image_loader) diff --git a/tests/unit/tools/test_prompt_image_generation_client.py b/tests/unit/tools/test_prompt_image_generation_client.py index 201d4086f8..7393d1effd 100644 --- a/tests/unit/tools/test_prompt_image_generation_client.py +++ b/tests/unit/tools/test_prompt_image_generation_client.py @@ -9,11 +9,11 @@ class TestPromptImageGenerationClient: - @pytest.fixture + @pytest.fixture() def image_generation_engine(self) -> Mock: return Mock() - @pytest.fixture + @pytest.fixture() def image_generator(self, image_generation_engine) -> PromptImageGenerationClient: return PromptImageGenerationClient(engine=image_generation_engine) diff --git a/tests/unit/tools/test_rest_api_client.py b/tests/unit/tools/test_rest_api_client.py index 83dc303504..58f21d1f15 100644 --- a/tests/unit/tools/test_rest_api_client.py +++ b/tests/unit/tools/test_rest_api_client.py @@ -4,7 +4,7 @@ class TestRestApi: - @pytest.fixture + @pytest.fixture() def client(self): from griptape.tools import RestApiClient diff --git a/tests/unit/tools/test_sql_client.py b/tests/unit/tools/test_sql_client.py index 0262be2d80..8ab61fc8f0 100644 --- a/tests/unit/tools/test_sql_client.py +++ b/tests/unit/tools/test_sql_client.py @@ -8,7 +8,7 @@ class TestSqlClient: - @pytest.fixture + @pytest.fixture() def driver(self): new_driver = SqlDriver(engine_url="sqlite:///:memory:") diff --git a/tests/unit/tools/test_structure_run_client.py b/tests/unit/tools/test_structure_run_client.py index 746115b05b..d498b7c568 100644 --- a/tests/unit/tools/test_structure_run_client.py +++ b/tests/unit/tools/test_structure_run_client.py @@ -7,7 +7,7 @@ class TestStructureRunClient: - @pytest.fixture + @pytest.fixture() def client(self): driver = MockPromptDriver() agent = Agent(prompt_driver=driver) diff --git a/tests/unit/tools/test_task_memory_client.py b/tests/unit/tools/test_task_memory_client.py index 9a55b49744..4276b89ec5 100644 --- a/tests/unit/tools/test_task_memory_client.py +++ b/tests/unit/tools/test_task_memory_client.py @@ -6,7 +6,7 @@ class TestTaskMemoryClient: - @pytest.fixture + @pytest.fixture() def tool(self): return TaskMemoryClient(off_prompt=True, input_memory=[defaults.text_task_memory("TestMemory")]) diff --git a/tests/unit/tools/test_text_to_speech_client.py b/tests/unit/tools/test_text_to_speech_client.py index 8d1ba78e68..0b9061aa6d 100644 --- a/tests/unit/tools/test_text_to_speech_client.py +++ b/tests/unit/tools/test_text_to_speech_client.py @@ -9,11 +9,11 @@ class TestTextToSpeechClient: - @pytest.fixture + @pytest.fixture() def text_to_speech_engine(self) -> Mock: return Mock() - @pytest.fixture + @pytest.fixture() def text_to_speech_client(self, text_to_speech_engine) -> TextToSpeechClient: return TextToSpeechClient(engine=text_to_speech_engine) diff --git a/tests/unit/tools/test_transcription_client.py b/tests/unit/tools/test_transcription_client.py index 94e00e333c..7768792d0e 100644 --- a/tests/unit/tools/test_transcription_client.py +++ b/tests/unit/tools/test_transcription_client.py @@ -7,11 +7,11 @@ class TestTranscriptionClient: - @pytest.fixture + @pytest.fixture() def transcription_engine(self) -> Mock: return Mock() - @pytest.fixture + @pytest.fixture() def audio_loader(self) -> Mock: loader = Mock() loader.load.return_value = AudioArtifact(value=b"audio data", format="wav") diff --git a/tests/unit/tools/test_variation_image_generation_client.py b/tests/unit/tools/test_variation_image_generation_client.py index bd824a95c3..ba707e5bb9 100644 --- a/tests/unit/tools/test_variation_image_generation_client.py +++ b/tests/unit/tools/test_variation_image_generation_client.py @@ -10,18 +10,18 @@ class TestVariationImageGenerationClient: - @pytest.fixture + @pytest.fixture() def image_generation_engine(self) -> Mock: return Mock() - @pytest.fixture + @pytest.fixture() def image_loader(self) -> Mock: loader = Mock() loader.load.return_value = ImageArtifact(value=b"image_data", format="png", width=512, height=512) return loader - @pytest.fixture + @pytest.fixture() def image_generator(self, image_generation_engine, image_loader) -> VariationImageGenerationClient: return VariationImageGenerationClient(engine=image_generation_engine, image_loader=image_loader) diff --git a/tests/unit/tools/test_vector_store_client.py b/tests/unit/tools/test_vector_store_client.py index 2e9c4037b1..b02dda2266 100644 --- a/tests/unit/tools/test_vector_store_client.py +++ b/tests/unit/tools/test_vector_store_client.py @@ -8,7 +8,7 @@ class TestVectorStoreClient: @pytest.fixture(autouse=True) - def mock_try_run(self, mocker): + def _mock_try_run(self, mocker): mocker.patch("griptape.drivers.OpenAiEmbeddingDriver.try_embed_chunk", return_value=[0, 1]) def test_search(self): diff --git a/tests/unit/tools/test_web_scraper.py b/tests/unit/tools/test_web_scraper.py index 9ba278586c..30362ce65c 100644 --- a/tests/unit/tools/test_web_scraper.py +++ b/tests/unit/tools/test_web_scraper.py @@ -4,7 +4,7 @@ class TestWebScraper: - @pytest.fixture + @pytest.fixture() def scraper(self): from griptape.tools import WebScraper diff --git a/tests/unit/tools/test_web_search.py b/tests/unit/tools/test_web_search.py index a2b488ff9e..dd447de5d9 100644 --- a/tests/unit/tools/test_web_search.py +++ b/tests/unit/tools/test_web_search.py @@ -5,7 +5,7 @@ class TestWebSearch: - @pytest.fixture + @pytest.fixture() def websearch_tool(self, mocker): mock_response = TextArtifact("test_response") driver = mocker.Mock() @@ -13,7 +13,7 @@ def websearch_tool(self, mocker): return WebSearch(web_search_driver=driver) - @pytest.fixture + @pytest.fixture() def websearch_tool_with_error(self, mocker): mock_response = Exception("test_error") driver = mocker.Mock() diff --git a/tests/unit/utils/test_load_artifact_from_memory.py b/tests/unit/utils/test_load_artifact_from_memory.py index c303f0954d..b479d76252 100644 --- a/tests/unit/utils/test_load_artifact_from_memory.py +++ b/tests/unit/utils/test_load_artifact_from_memory.py @@ -7,15 +7,15 @@ class TestLoadImageArtifactFromMemory: - @pytest.fixture + @pytest.fixture() def memory(self): return Mock() - @pytest.fixture + @pytest.fixture() def text_artifact(self): return TextArtifact(value="text", name="text") - @pytest.fixture + @pytest.fixture() def image_artifact(self): return ImageArtifact(value=b"image", name="image", format="png", height=32, width=32) @@ -26,19 +26,15 @@ def test_no_memory(self): def test_no_artifacts_in_memory(self, memory): memory.load_artifacts.return_value = [] - with pytest.raises(ValueError) as e: + with pytest.raises(ValueError, match="no artifacts found in namespace"): load_artifact_from_memory(memory, "", "", TextArtifact) - assert str(e) == "no artifacts found in namespace" - def test_no_artifacts_by_name(self, memory, text_artifact): memory.load_artifacts.return_value = [text_artifact] - with pytest.raises(ValueError) as e: + with pytest.raises(ValueError, match="artifact name not found in namespace"): load_artifact_from_memory(memory, "namespace", "other_name", TextArtifact) - assert str(e) == "artifact name not found in namespace" - def test_returns_one_artifact(self, memory, text_artifact): memory.load_artifacts.return_value = [text_artifact] @@ -56,7 +52,5 @@ def test_returns_multiple_artifacts(self, memory, text_artifact, image_artifact) def test_wrong_artifact_type(self, memory, image_artifact): memory.load_artifacts.return_value = [image_artifact] - with pytest.raises(ValueError) as e: + with pytest.raises(ValueError, match="artifact is not of type ImageArtifact"): load_artifact_from_memory(memory, "namespace", image_artifact.name, TextArtifact) - - assert str(e) == "artifact is not of type ImageArtifact" diff --git a/tests/unit/utils/test_message_stack.py b/tests/unit/utils/test_message_stack.py index 908388a330..799705a546 100644 --- a/tests/unit/utils/test_message_stack.py +++ b/tests/unit/utils/test_message_stack.py @@ -5,7 +5,7 @@ class TestPromptStack: - @pytest.fixture + @pytest.fixture() def prompt_stack(self): return PromptStack() diff --git a/tests/unit/utils/test_stream.py b/tests/unit/utils/test_stream.py index e223a5c259..767d31ba0f 100644 --- a/tests/unit/utils/test_stream.py +++ b/tests/unit/utils/test_stream.py @@ -22,9 +22,9 @@ def test_init(self, agent): chat_stream_artifact = next(chat_stream_run) assert chat_stream_artifact.value == "mock output" + next(chat_stream_run) with pytest.raises(StopIteration): next(chat_stream_run) - next(chat_stream_run) else: with pytest.raises(ValueError): Stream(agent)