This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wandermonk
Recipients wandermonk, xtreak
Date 2021-08-27.09:48:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAFu-X9XHY4V+E7sPcmnzkGVpKJyzFAqx1Ym4h8QFLVqRxEYJ9w@mail.gmail.com>
In-reply-to <1630050540.87.0.525095871851.issue45028@roundup.psfhosted.org>
Content
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>
> _______________________________________
>
History
Date User Action Args
2021-08-27 09:48:43wandermonksetrecipients: + wandermonk, xtreak
2021-08-27 09:48:43wandermonklinkissue45028 messages
2021-08-27 09:48:43wandermonkcreate