Skip to content

refactor: replace patch.object(logger) with caplog in Weaviate tests#38400

Open
BlueLi66 wants to merge 2 commits into
langgenius:mainfrom
BlueLi66:fix/replace-patch-logger-with-caplog
Open

refactor: replace patch.object(logger) with caplog in Weaviate tests#38400
BlueLi66 wants to merge 2 commits into
langgenius:mainfrom
BlueLi66:fix/replace-patch-logger-with-caplog

Conversation

@BlueLi66

@BlueLi66 BlueLi66 commented Jul 3, 2026

Copy link
Copy Markdown

Replace patch.object(logger) with pytest caplog fixture in Weaviate vector tests.

  • test_shutdown_client_logs_debug_when_close_fails: use caplog.at_level(logging.DEBUG)
  • test_create_collection_logs_and_reraises_errors: use caplog.at_level(logging.ERROR)
  • test_ensure_properties_logs_warning_when_property_addition_fails: use caplog.at_level(logging.WARNING)

#37468

This is my first try in "good issue"

@BlueLi66 BlueLi66 requested a review from QuantumGhost as a code owner July 3, 2026 12:53
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. refactor labels Jul 3, 2026
asukaminato0721
asukaminato0721 previously approved these changes Jul 4, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 4, 2026
@asukaminato0721 asukaminato0721 enabled auto-merge July 4, 2026 04:41
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-07-04 04:49:21.126380568 +0000
+++ /tmp/pyrefly_pr.txt	2026-07-04 04:49:06.071280925 +0000
@@ -453,13 +453,13 @@
 ERROR Object of class `ModuleType` has no attribute `VikingDBService` [missing-attribute]
   --> providers/vdb/vdb-vikingdb/tests/unit_tests/test_vikingdb_vector.py:76:5
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_weaviate.weaviate_vector.WeaviateVector.get_collection_name` [bad-argument-type]
-   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:170:39
+   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:171:39
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_weaviate.weaviate_vector.WeaviateVector.get_collection_name` [bad-argument-type]
-   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:177:43
+   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:178:43
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_weaviate.weaviate_vector.WeaviateVectorFactory.init_vector` [bad-argument-type]
-   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:891:42
+   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:892:42
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_weaviate.weaviate_vector.WeaviateVectorFactory.init_vector` [bad-argument-type]
-   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:920:42
+   --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:921:42
 ERROR Object of class `FromClause` has no attribute `metadata` [missing-attribute]
   --> tests/helpers/legacy_model_type_migration.py:64:16
 ERROR Object of class `FromClause` has no attribute `metadata` [missing-attribute]

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 52.30% 52.30% -0.00%
Strict coverage 51.82% 51.82% -0.00%
Typed symbols 32,027 32,027 0
Untyped symbols 29,478 29,481 +3
Modules 2970 2970 0

@asukaminato0721

Copy link
Copy Markdown
Contributor

=========================== short test summary info ============================
FAILED api/providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py::TestWeaviateVector::test_create_collection_logs_and_reraises_errors - TypeError: TestWeaviateVector.test_create_collection_logs_and_reraises_errors() missing 1 required positional argument: 'caplog'
FAILED api/providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py::TestWeaviateVector::test_ensure_properties_logs_warning_when_property_addition_fails - TypeError: TestWeaviateVector.test_ensure_properties_logs_warning_when_property_addition_fails() missing 1 required positional argument: 'caplog'
FAILED api/providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py::TestWeaviateVector::test_shutdown_client_logs_debug_when_close_fails - TypeError: TestWeaviateVector.test_shutdown_client_logs_debug_when_close_fails() missing 1 required positional argument: 'caplog'
===== 3 failed, 12992 passed, 4 skipped, 532 warnings in 243.72s (0:04:03) =====

@asukaminato0721 asukaminato0721 self-assigned this Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants