Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing section to docs #179

Open
trp07 opened this issue Oct 10, 2021 · 2 comments
Open

Add testing section to docs #179

trp07 opened this issue Oct 10, 2021 · 2 comments
Labels
📕 docs documentation update needed

Comments

@trp07
Copy link

trp07 commented Oct 10, 2021

Good evening,

I know issues might not be the best place to ask this, but I can't seem to find anything online. Any assistance is greatly appreciated!

How might someone write a unit test in PyTest to test a function that calls aiosmtplib.send() inside it?

For example:

# Function in my application
async def myfunc():
    call_some_other_func()
    await aiosmtplib.send(...)

# Unit testing with PyTest
@pytest.mark.asyncio
async def test_myfunc():
    # what goes here?
@trp07
Copy link
Author

trp07 commented Oct 12, 2021

I got everything I needed from this tutorial:
https://agariinc.medium.com/strategies-for-testing-async-code-in-python-c52163f2deab

AsyncMock is native to python 3.8, but the tutorial shows how to create one for earlier python versions.

Apologies for opening an issue on the topic. I’ll close it with this comment :)

@trp07 trp07 closed this as completed Oct 12, 2021
@cole cole reopened this Oct 12, 2021
@cole
Copy link
Owner

cole commented Oct 12, 2021

Going to reopen as a reminder to add a testing section to the docs 🙂

@cole cole changed the title Pytest Assistance Add testing section to docs Oct 12, 2021
@cole cole added the 📕 docs documentation update needed label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📕 docs documentation update needed
Projects
None yet
Development

No branches or pull requests

2 participants