Skip to content

fix: remove document mutation from weaviate tests#3160

Open
srini047 wants to merge 1 commit intodeepset-ai:mainfrom
srini047:weaviate-mutate
Open

fix: remove document mutation from weaviate tests#3160
srini047 wants to merge 1 commit intodeepset-ai:mainfrom
srini047:weaviate-mutate

Conversation

@srini047
Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Ensure to use replace() instead of mutating docs in place.

How did you test it?

Before change:

➜  weaviate git:(weaviate-mutate) hatch run test:all tests/test_document_store.py::TestWeaviateDocumentStore::test_write_documents                 
========================================================================================= test session starts ==========================================================================================
platform darwin -- Python 3.12.10, pytest-9.0.3, pluggy-1.6.0
rootdir: /Users/apple/Documents/haystack-core-integrations/integrations/weaviate
configfile: pyproject.toml
plugins: cov-7.1.0, asyncio-1.3.0, rerunfailures-16.1, anyio-4.13.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item                                                                                                                                                                                       

tests/test_document_store.py .                                                                                                                                                                   [100%]

=========================================================================================== warnings summary ===========================================================================================
tests/test_document_store.py::TestWeaviateDocumentStore::test_write_documents
  /Users/apple/Documents/haystack-core-integrations/integrations/weaviate/tests/test_document_store.py:376: Warning: Mutating attribute 'content' on an instance of 'Document' can lead to unexpected behavior by affecting other parts of the pipeline that use the same dataclass instance. Use `dataclasses.replace(instance, content=new_value)` instead. See https://docs.haystack.deepset.ai/docs/custom-components#requirements for details.
    doc.content = "test doc 2"

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================================== 1 passed, 1 warning in 3.64s =====================================================================================
➜  weaviate git:(weaviate-mutate) hatch run test:all tests/test_document_store_async.py::TestWeaviateDocumentStoreAsync::test_write_documents_async
========================================================================================= test session starts ==========================================================================================
platform darwin -- Python 3.12.10, pytest-9.0.3, pluggy-1.6.0
rootdir: /Users/apple/Documents/haystack-core-integrations/integrations/weaviate
configfile: pyproject.toml
plugins: cov-7.1.0, asyncio-1.3.0, rerunfailures-16.1, anyio-4.13.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item                                                                                                                                                                                       

tests/test_document_store_async.py .                                                                                                                                                             [100%]

=========================================================================================== warnings summary ===========================================================================================

After change:

➜  weaviate git:(weaviate-mutate) ✗ hatch run test:all tests/test_document_store.py::TestWeaviateDocumentStore::test_write_documents                 
========================================================================================= test session starts ==========================================================================================
platform darwin -- Python 3.12.10, pytest-9.0.3, pluggy-1.6.0
rootdir: /Users/apple/Documents/haystack-core-integrations/integrations/weaviate
configfile: pyproject.toml
plugins: cov-7.1.0, asyncio-1.3.0, rerunfailures-16.1, anyio-4.13.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item                                                                                                                                                                                       

tests/test_document_store.py .                                                                                                                                                                   [100%]

========================================================================================== 1 passed in 3.35s ===========================================================================================
➜  weaviate git:(weaviate-mutate) ✗ hatch run test:all tests/test_document_store_async.py::TestWeaviateDocumentStoreAsync::test_write_documents_async
========================================================================================= test session starts ==========================================================================================
platform darwin -- Python 3.12.10, pytest-9.0.3, pluggy-1.6.0
rootdir: /Users/apple/Documents/haystack-core-integrations/integrations/weaviate
configfile: pyproject.toml
plugins: cov-7.1.0, asyncio-1.3.0, rerunfailures-16.1, anyio-4.13.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item                                                                                                                                                                                       

tests/test_document_store_async.py .                                                                                                                                                             [100%]

========================================================================================== 1 passed in 3.01s ===========================================================================================

Notes for the reviewer

Checklist

@srini047 srini047 requested a review from a team as a code owner April 13, 2026 16:50
@srini047 srini047 requested review from bogdankostic and removed request for a team April 13, 2026 16:50
@github-actions
Copy link
Copy Markdown
Contributor

Coverage report (weaviate)

This PR does not seem to contain any modification to coverable code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check for WeaviateDocumentStore dataclass in-place mutation warning

1 participant