from unittest import mock
@mock.patch(
"project.celerytasks.embedder.BulkEmbedder.fetch_embedding",
mock.AsyncMock(return_value=embedding_response),
)
def test_document_embedding():
doc = {
"orgId": "orgtest"
}
doc = embed(document=doc, embedding_endpoint=embedding_endpoint)
assert doc["subdocuments"]
assert len(doc["title_embedding"]) == embedding_dim
assert len(doc["subdocuments"]) == len(doc["paragraphs"])
assert len(doc["subdocuments"][0][embedding_name]) == embedding_dim
Error:
____________________________________________________________________________________________________________________
ERROR collecting code/tests/test_embedder.py
____________________________________________________________________________________________________________________
tests/test_embedder.py:18: in <module>
mock.AsyncMock(return_value=embedding_response),
E AttributeError: module 'unittest.mock' has no attribute 'AsyncMock'
==============================================================================================================================
short test summary info
===============================================================================================================================
ERROR tests/test_embedder.py - AttributeError: module 'unittest.mock' has
no attribute 'AsyncMock'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Interrupted: 1 error during collection
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================================================================================================
1 error in 6.02s
==================================================================================================================================
Regards
Phani kumar yadavilli
On Fri, Aug 27, 2021 at 1:19 PM Karthikeyan Singaravelan <
report@bugs.python.org> wrote:
>
> Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment:
>
> Can you please add a sample script to reproduce the problem. It will be
> also helpful to add how you run the script and also attach the error
> message you are getting. Given that you have selected Python 3.7 version
> AsyncMock was added in Python 3.8 . For Python 3.7 you might want to use
> the backport of mock.
>
> ----------
> nosy: +xtreak
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue45028>
> _______________________________________
>
|